Prime Factors Flow Chart

ADVERTISEMENT

Prime Factors Flow Chart
Introduction to Programming I
10 Points
Create a flow chart that will compute (or write out) the prime factors of a given number. The prime factors of a number are
the set of prime numbers that, when multiplied together, produce the number. For example, the prime factors of 30 are 2, 3,
and 5 since 30 = 2 x 3 x 5. The prime factors of 8 are 2, 2, and 2 since 8 = 2 x 2 x 2.
You will need to use the basic primitives that all our flow charts have used thus far: get a number, write out a number,
addition, subtraction, multiplication, division, finding remainders, comparisons, etc. Additionally, you can use a
subprocess that determines if a number is prime or not. For example:
Determine if
X is prime
yes
no
Is X prime?
Hint: The easiest way to compute the prime factors of a number is to use a method similar to how we would find all the
prime numbers between 1 and 1000. Test the numbers from 2 to X to determine if they are prime and if they evenly divide
X (the remainder of X divided by the number is 0). Then divide X by the prime number and make it your new X, and
repeat the procedure until X is prime.
You may use the OverFlow program to produce your flow chart (although it won’t run in OverFlow since it does not
contain a subprocess symbol), or write it on a piece of paper. Turn in your flow at the beginning of the next class period.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go