That number cannot be divisible by any other number. So if we try to divide that number by any other number between one and that number, we will get a remainder. Here is a sample PHP script program to create a list of prime numbers According to the prime number definition number one ( 1 ) wont consider as a primer number. In this example we are going to print first 20 prime numbers. Logic of this program : We need first store the current number to a variable. And we will increment a counter if remainder found zero.Īnd then we will find the remainder for each division of other numbers with the stored number using a loop. Here is a sample PHP script program to create a list of prime numbers. After all the division operations with other numbers we will check the total counter for the remainder. number by any other number between one and that number, we will get a remainder. If its value greater than two means, that number can be divisible by some other number instead of 1 and that number itself.If its value less than three means, its a primer number. Now look at another PHP script for generating a list of prime numbers below 100. This not only the one method of logic to create Primer number series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |