06-02-2003, 11:34 PM
Code:
CLS
DIM prime(1 TO 5000) AS INTEGER, cur.prime.amount AS INTEGER
cur.prime.amount% = 1
prime%(1) = 2
i% = 3
1 j% = 0
sqrt.num% = SQR(i%)
2 j% = j% + 1
temp% = prime%(j%)
IF i% MOD temp% = 0 THEN GOTO 4
IF temp% >= sqrt.num% THEN GOTO 3
GOTO 2
3 cur.prime.amount% = cur.prime.amount% + 1
prime%(cur.prime.amount%) = i%
4 IF i% = 32767 THEN GOTO 5
i% = i% + 2
GOTO 1
5 i2& = prime(cur.prime.amount%)
i2& = i2& + 2
biggest.prime& = i2&
i3# = TIMER + 1
6 j% = 1
sqrt.num% = SQR(i2&)
7 temp% = prime(j%)
IF i2& MOD temp% = 0 THEN GOTO 9
IF temp% >= sqrt.num% THEN GOTO 8
j% = j% + 1
GOTO 7
8 biggest.prime& = i2&
9 i2& = i2& + 2
IF TIMER > i3# THEN i3# = TIMER + 1: PRINT biggest.prime&
GOTO 6
'IF INKEY$ = "" THEN GOTO 6
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Visit www.neobasic.net to see rubbish in all its finest.