Welcome to WebmasterWorld Guest from 54.211.222.233 register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts, Become a Pro Member
 Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque

# Webmaster General Forum

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

Msg#: 4076379 posted 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#: 4076379 posted 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#: 4076379 posted 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#: 4076379 posted 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  Tweet

 Home / Forums Index / WebmasterWorld / Webmaster General