Pages

Monday, 18 August 2014

Home » » Prime Number Algorithm

Prime Number Algorithm

oke, on this posting, i wanna share for alghoritm of prime number.

1. set n ;                // 1 Direct Assignment
2. Display "Enter The Number : "    // n Writes
3. Accept n ;                // 1 Indirect Assignment
4. set k = 0                 // 1 Direct Assignment
5. set i = 1                // 1 Direct Assignment
6. while (i<= n)            // n Comparison
a. if (num % i == 0)            // 1 Assignment
    i. k increment by 1;        // n x n increment
7. i increment by 1            // n increment
8. if(k == 2 )                // 1 Assignment
   a. Display "This Is Prime Number";    // n Writes
      else        
   b. Display "This is Not Prime Number" ;



Share this article :

Post a Comment