with reference to images attached, draw a flow chart(visual) for the following question based on javascript computational thinking  Given a 1D array of 100 numbers, find all pairs that are prime to each other (i.e., their GCD is 1).

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
icon
Related questions
Question

with reference to images attached, draw a flow chart(visual) for the following question based on javascript computational thinking

 Given a 1D array of 100 numbers, find all pairs that are prime to each other (i.e., their GCD is 1).

Advanced Example 10
Devise a program to receive
a positive number, and print
all prime numbers less than
or equal to that number
We are going to reuse our solution to
Advanced Example 4 (to check if a
number is prime or not). we need to
modify it a bit to return a True or False
answer though.
York University EECS 1012F2023
...continued
This is called sub-algorithm
A sub-algorithm is called from
other algorithms
We called the prime sub-
algorithm from inside our AE10
When tracing an algorithm, we
normally treat sub-algorithms
as a black box (and we assume
they are correct)
precondition: num = N
postcondition: output all prime
numbers ≤ num
Exercise: trace advanced
example 10, for when input is 8
York University EECS 1012 F2023
14-2
start
num
1<--1+1
prime(/) = true
T
end
is num
Comp. Thinking (pt 3: Verification) 23
precondition: num>1 € N
postcondition: returns true if
num is prime, otherwise
returns false.
prime(num)
start
flag-true
d←2
flag true and
ds num/2
num mod d=0
flag-false
d+d+1
F
ret flag
Comp. Thinking (pt 3: Verification) 24
F
Transcribed Image Text:Advanced Example 10 Devise a program to receive a positive number, and print all prime numbers less than or equal to that number We are going to reuse our solution to Advanced Example 4 (to check if a number is prime or not). we need to modify it a bit to return a True or False answer though. York University EECS 1012F2023 ...continued This is called sub-algorithm A sub-algorithm is called from other algorithms We called the prime sub- algorithm from inside our AE10 When tracing an algorithm, we normally treat sub-algorithms as a black box (and we assume they are correct) precondition: num = N postcondition: output all prime numbers ≤ num Exercise: trace advanced example 10, for when input is 8 York University EECS 1012 F2023 14-2 start num 1<--1+1 prime(/) = true T end is num Comp. Thinking (pt 3: Verification) 23 precondition: num>1 € N postcondition: returns true if num is prime, otherwise returns false. prime(num) start flag-true d←2 flag true and ds num/2 num mod d=0 flag-false d+d+1 F ret flag Comp. Thinking (pt 3: Verification) 24 F
Advanced Example 5
start
sum 0
i ← 1
i←i + 1
i≤ 100
T
sumsum + a[i]
"sum = ", sum
end
Devise a program to
output sum of values
stored in an array of
100 elements
precondition: a; E R, 1 ≤ i ≤ 100
postcondition: a₁is outputted
100
Transcribed Image Text:Advanced Example 5 start sum 0 i ← 1 i←i + 1 i≤ 100 T sumsum + a[i] "sum = ", sum end Devise a program to output sum of values stored in an array of 100 elements precondition: a; E R, 1 ≤ i ≤ 100 postcondition: a₁is outputted 100
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning