Saturday, August 18, 2012

Prime Count between limits

Assalamu Alaikum. Hope, you all are well by the grace of Almighty ALLAH. Today we learn how to count prime numbers between limits. Take a look at the problem.

Problem: Write a program that prints the number of total prime numbers between X and Y, where Y > X. If X is lower than Y, a message will be given "Invalid Range".



Solution:
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Now, take a look at the program.


We can also do this program by using a flag. Now take a look at the following program.


Thank You all..



0 comments:

Post a Comment