Math, asked by poll4732, 11 months ago

If a factor of a number is a prime number then it is its prime factor. Write an algorithm to find the prime factor of a number.

Answers

Answered by iadarsh
16

Answer:

Step-by-step explanation:

Algorithm to find the prime factor of a number:

START

Input a number from the user. Store it in some variable say N.

Run a loop from 2 to N/2, increment 1 in each iteration. The loop structure should look like for(i=2; i<=N/2; i++).

You may think why loop from 2 to N/2? Because prime number starts from 2 and any factor of a number N is always less than N/2.

Inside the loop, first, check if i is a factor of N or not. If it is a factor then check it is prime or not.

Print the value of i if it is prime and a factor of N.

END

Similar questions