I Am Facing A Problem Working With Prime Number.

Could You Send The Code?

From,

Chetna

I cannot send you the code. Your problem is not defined clearly.

"Working with Prime number" means what ? Are you manipulating prime

numbers ?

If you want to display prime numbers, then this is the algorithm

1. put a for loop from 4 to the highest number you want

[ for example 1 to 100 print prime numbers, like wise]

Here 2,3 are prime numbers print them directly if they are in the range.

0 and 1 are neither prime nor composite so leave them.

2. Have a flag with initial value true

3. Nest with another for loop, Let the variable of outer for loop be i and

inner be j

4. Now intialise j from zero to square root of i

5. In this inner loop check whether j divides i, that is reminder is zero

make use of "%" operator.

6. If the reminder is zero, then make the flag false and break the inner loop

7. After inner loop, before closing outer loop; check the flag, if it is true

then display variable i, since it is prime and close the outer for loop

Is it all clear now ???

Post whether this is the one you are looking for

Regards,

Girish.