|
|||||||||||||||||
![]() |
![]() |
![]() |
|||||||||||||||
|
Algorithm to compute prime factor
Now we proceed with algorithm (method) to compute prime factor manually by hand computation. The simplest algorithm to find the prime-factor is by repeatedly dividing the number with the prime factor until the number becomes 1.
When we use procedural programming, the algorithm of prime factor is as follow Input N p = 2 Print N & “= “ Do while N > = p * p If N mod p = 0 then Print p & “*” N = N / p (divide by prime number) Else p = p + 1 End If Loop Print N The flow chart of above algorithm is shown below.
After learning about divisors, prime and composite number as well as prime factorization, you may want to try the following online Divisibility-Prime-Factorization calculator. This interaction program below determines whether your input is a prime or composite number. If it is a composite number, the program will list the divisors and gives the prime factorization which is unique for your input number. In the next section, we will discuss slightly more challenging problem: how to calculate prime factor of any positive integer in Spreadsheet without macro (without do while loop). You need to think to do it in parallel programming. < Previous | Next | Content>Preferable reference for this tutorial is Teknomo, Kardi (2010) Prime factor tutorial. http:\\people.revoledu.com\kardi\ tutorial\BasicMath\Prime\
|
|||||||||||||
|
||||||||||||||
|
||||||||||||||