Posts: 2,020
Threads: 24
Joined: Jun 2002
low budget canadian movies should only be watched in the backdrop of an mst3k episode...
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:whitetiger0990 Wrote:nope... It finds prime numbers
If I'm reading that correctly, it looks like 35 is a prime. Reminds me of the Cube *shudders at the awfulness of low budget canadian films*
Well it is sometimes both sub. and add. Sometimes not.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,368
Threads: 195
Joined: Jan 2003
See Challenges post regarding impossibility of prime number equation.
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.
Posts: 2,020
Threads: 24
Joined: Jun 2002
It's a nice little trick, like 7/22 for pi, but it skips over numbers, and after awhile will start producing non-primes. This table has primes on the left, and 6x+1 and 6x-1 on the other side.
Code:
3 1 -1
5 7 5
7 13 11
11 19 17
13 25 23
17 31 29
19 37 35
23 43 41
29 49 47
31 55 53
37 61 59
41 67 65
43 73 71
47 79 77
53 85 83
59 91 89
61 97 95
67 103 101
71 109 107
73 115 113
79 121 119
83 127 125
89 133 131
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 704
Threads: 0
Joined: Dec 2002
produce prime numbers sometimes but not always.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3,288
Threads: 167
Joined: Nov 2001
I guess I'll stick it out with Erathosthenes' Seive. :*)
Posts: 2,765
Threads: 138
Joined: Nov 2002
I use it like this -
Code:
CLS
INPUT n
FOR i = 1 TO n
a = i * 6 - 1
b = i * 6 + 1
IF a <= n THEN
z = 1
DO
z = z + 1
IF z = a THEN PRINT a: EXIT DO
IF a / z = INT(a / z) THEN EXIT DO
LOOP
END IF
IF b <= n THEN
z = 1
DO
z = z + 1
IF z = b THEN PRINT b: EXIT DO
IF b / z = INT(b / z) THEN EXIT DO
LOOP
END IF
NEXT
I made a section that makes sure the numberis divisible only by 1 and itself. Oh and the formula is only good for primes bigger than 3
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Easy to fix: if inputted value is larger than 2 or 3 then output them. But I'm too lazy to rewrite your code :wink: