homepage Welcome to WebmasterWorld Guest from 54.243.12.156
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
pls help write a pascal program to find the prime numbers btw 1 and 200
mailtimi




msg:4076381
 3:46 pm on Feb 8, 2010 (gmt 0)

pls i was given these assignment at school and i would be having a test on dis course tomorrow.pls it is very urgent.would appreciate it if any1 could help me write a pascal program to find the prime numbers between 1 and 200.

 

mark_roach




msg:4076385
 4:06 pm on Feb 8, 2010 (gmt 0)

Not pascal but rexx.


do i=1 to 200
p=0
do j=1 to i until p > 2
if i // j = 0 then
p=p+1
end
if p=2 then
say i' is prime'
end


You didn't think anyone was going to hand it to you on a plate did you :-)

lammert




msg:4076703
 1:18 am on Feb 9, 2010 (gmt 0)

This is the fastest and smallest Pascal implementation I can think of. I don't know if they will accept it. It should be accepted though because the output of the program fits the assignment.

BEGIN
WriteLn( '2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,73,79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199' );
END

Dijkgraaf




msg:4076734
 3:05 am on Feb 9, 2010 (gmt 0)

They still teach pascal? Wow.
I wrote a program like that over 20 years ago.

Just do a search in your favourite search engine for pascal prime number and I'm sure you will find some (I did, and the code was published in 1990).
But doing that defeats the purpose of doing it yourself, as you will learn things from doing it, rather than copying someone else. So if you want to actually become a programmer, try and do it yourself, or at the very least make sure you understand the code you download fully.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved