Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ cannot write this BASIC PROGRAM

Name: Anonymous 2008-05-08 20:11

Task: Using your language of choice, implement a program that will a) Prompt the user for 2 numbers, and b) output the number of prime numbers between the two numbers (inclusive.)

Output: A B N

Name: Anonymous 2008-05-08 20:26

thats not that hard, but im not spending any time writing it

>prompt user for number
>input number into m and n
>call count primes

count primes:
>loop through m to n with i
>call isprime(i)
>if isprime(i) is true count + 1
>return count

isprime :
if i < 1 return no
if i == 1 return no
if lowestdenominator i == i return yes

lowestdenominator:
loop through 2 to i with k
if k divides i return k
if k^2 > i return i
else lowestdenominator k+1

that should work

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List