- #1
ramsey2879
- 841
- 3
Does anyone have any comment on the usefulness of the following test?
Input P
Prime = true
Triangular = 0
n = 0
Do until Triangular > P
n = n + 1
Triangular = Triangular + n
loop
X = Triangular Mod P
Do
Y = Int(Sqr(2*X))
' Comment if X is triangular then (Y*Y+Y)/2 = X
If (Y*Y+Y)/2 = X then
Prime = False
Exit Do
End If
n = n + 1
X = (X+ n) mod P
loop until n = (P+1)/2
Print "P is prime is " & Prime
Edit: I forgot to mention that this test does not work for primes less than 11 since then the sum of all numbers from 1 to (P-1)/2 is not greater than P but I checked it as an Excel macro for all odd numbers between 8 and 90,000 and the test worked perfectly.
Input P
Prime = true
Triangular = 0
n = 0
Do until Triangular > P
n = n + 1
Triangular = Triangular + n
loop
X = Triangular Mod P
Do
Y = Int(Sqr(2*X))
' Comment if X is triangular then (Y*Y+Y)/2 = X
If (Y*Y+Y)/2 = X then
Prime = False
Exit Do
End If
n = n + 1
X = (X+ n) mod P
loop until n = (P+1)/2
Print "P is prime is " & Prime
Edit: I forgot to mention that this test does not work for primes less than 11 since then the sum of all numbers from 1 to (P-1)/2 is not greater than P but I checked it as an Excel macro for all odd numbers between 8 and 90,000 and the test worked perfectly.
Last edited: