If you look at the part called Similar Threads at the bottom of this webpage you will find a lot of threads with examples.
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
It is easy..
For each number from 2 to TheSpecificNumber
If number is a prime number
Print number
Else
Dont Print it
End if
End For
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
i want to know how to dispaly a series of number. Supose an user input a number(40). The progrme will generate and display like this way:
1-prime
2-not prime
3-prime
4-not prime
5-prime
6-prime
upto
40-prime
plz solve my proble. I will b grateful to u.
One, you've already asked this here: http://www.daniweb.com/forums/thread126749.html
Two, this thread is over a year old. Stick with the thread you already have. If you show some effort, you'll get better help than you have so far.
Three, I can't make any sense of the example you gave. 6 is not prime, 2 is prime.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
I hope not because 1 is not a prime number* and 2 is.
You have already got code that checks a number to see if it is prime in your own post (although it code stand some optimisation). All you have to do is repeat that in a loop for every number you wish to check, better still put it in a function and then call that function from the loop.
* What is 1 not considered prime? - in short it would break too many other Maths theorems if it was.
Banfa
Practically a Master Poster
600 posts since Mar 2010
Reputation Points: 486
Solved Threads: 92