


The modulo operator returns 0 if a is perfectly divisible by b indicating the fact that b as a smaller natural number is a factor for the composite number a. The loop then passes through the range and uses the natural operation of modulo on the variable a by the divisor b. The program above uses a lower limit of Natural number i.e.2 defining ‘a’ as a natural number in the range of 2 ranging to 99 with the post-operation increment of 1, the next step uses a variable ‘b’ with the similar range but bound to a condition in its upper limit is always less than ‘a’. Program Explanation: The above program is a classic example of the use of loops and conditional operators for determining the prime numbers in a fixed range of numbers. If (a != b & a % b = 0) //modulo operators employedĬonsole.Write("\t" + a) //printing the correct variableĬonsole.ReadKey() //hold the output screen Static void Main(string args) // this function defines the entry pointĬonsole.WriteLine("Prime Numbers between 1 to 100 : ") įor (int a = 2 a <= 100 a++) //upper limit and lower limit are definedįor (int b = 2 b <= 100 b++)// base logic for the primality
SQL LIST OF PRIME NUMBERS SOFTWARE
Web development, programming languages, Software testing & others Example #1Ĭ# program to print the list of all prime numbers between 1 to 100.
SQL LIST OF PRIME NUMBERS FREE
Start Your Free Software Development Course
