Logic is same for all programs and only programming statements are different. Here we have given php programming logic to find given number is prime or not.
What is prime Number:
What is prime Number:
- A Prime Number can be divided evenly only by 1, or itself.
- For example : 5 can only be divided by 1 or 5, so it is a prime number.
- But 6 can be divided by 1, 2, 3 and 6 so it is NOT a prime number.
Prime Number Programming Logic:
- We should do modulo operation for the input number from 1 to input number. ie) 3 % 1 == 0 , 3 % 2 == 1 and 3 % 3 == 0.
- Each and every prime number will get two '0' modulo result.
- So, each time when modulo result occurs 0, increment the count variable, ie) count++
- After that check the condition that, if count variable == 2, input number is prime else not a prime number
3 is a Prime number
Click Here to get -- > Php Tutorials by Studentsblog100
Thank you verrrrrrrrrrrrry much...
ReplyDeleteExcellent post. I was checking constantly this blog and I am
ReplyDeleteimpressed! Very helpful
Real Estate Brokers in Chennai