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).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education