Computer Science, asked by mashahzad2010, 1 month ago

input a number and display its factors by drawing a flow chart​

Answers

Answered by dheepikarameshkumar
0

Answer:

Before trying to write the flowchart try writing the algorithm in a human language such as English.

The English description of an algorithm to print the prime factors of a number is:

While n is divisible by 2, print 2 and divide n by 2.

After step 1, n must be odd. Now start a loop from i = 3 to square root of n. While i divides n, print i and divide n by i, increment i by 2 and continue.

If n is a prime number and is greater than 2, then n will not become 1 by above two steps. So print n if it is greater than 2.

Step one requires a loop to print out all the times 2 is a factor of the number.

Step two requires an outer loop and a nested loop to identify all the odd factors less than the square root of the number.

Step three is needed if the input number is itself a prime number greater than 2.

A flowchart for this algorithm can be written as:

Explanation:

Similar questions