|
|
Re: Prime Numbers
|
Posted: Feb 21, 2003 5:24 AM
|
|
try to code this:
1: print "Enter start range" 2: read start 3: check the end range, it should be greater than start, otherwise inform the user to enter again 4: set correctInput equal to false 5: while (correctInput equal to false) 6: begin 7: print "Enter end range : " 8: read end; 9: if (end > start) 10: set correctInput equal to true 11: end_if 12: end 13: set counter equal to start 14: while (counter less than or equal to end) 15: begin 16: set limit equal to square root of counter 17: set denum equal to 2 18: set isPrime equal to true 19: while (denum is less than or equal to limit) 20: begin 21: if (counter modulos denum equal to zero) 22: set isPrime equal to false 23: end_if 24: increment denum by 1; 25: end_while 26: if (isPrime) 27: print(counter) 28: increment counter by 1 29: end_while
|
|