how to find out number is prime or not in webmethod
Answers
Answered by
1
a prime number is a number which is only divisible by itself and 1 like 13 17 19 23 etc
Answered by
1
let the given no. be n
we have to divide the no. from 2 to (n-1)
if at any time remainder = 0 then no. is not prime
and if rem. is not equal to 0 then no. is prime
eg.
no.=7
we have to divide 7 from
2 to 6 => 2,3,4,5,6
7/2 => rem.=1
7/3 => rem. =1 and so on
here it is clear that rem. is not equal to zero in any case so 7 is a prime no.
we have to divide the no. from 2 to (n-1)
if at any time remainder = 0 then no. is not prime
and if rem. is not equal to 0 then no. is prime
eg.
no.=7
we have to divide 7 from
2 to 6 => 2,3,4,5,6
7/2 => rem.=1
7/3 => rem. =1 and so on
here it is clear that rem. is not equal to zero in any case so 7 is a prime no.
powerstarmaru:
i want ansr in web methods
Similar questions