Loading ...
Sorry, an error occurred while loading the content.

T3 Sequence

Expand Messages
  • leavemsg1
    The following is a program written in BASIC: It doesn t use trial factoring, or exponentiation; It uses what the author describes as a T3 sequence. just cut
    Message 1 of 1 , Jan 30, 2008
    • 0 Attachment
      The following is a program written in BASIC:
      It doesn't use trial factoring, or exponentiation;
      It uses what the author describes as a T3 sequence.
      just cut and paste it... and run it...
      It works in polynomial time and is deterministic.
      The results are fool proof... and I can discuss it with anyone.

      38 CLS
      40 INPUT N
      42 DIM A(100)
      44 A(0) = N: A(1) = (N + 1) / 2: A(2) = A(1) - 1
      46 FOR I = 0 TO 2: PRINT I, A(I): NEXT I
      48 FOR J = 3 TO 100 STEP 2
      50 IF A(J - 1) <= 2 THEN
      52 IF A(J - 1) = 2 THEN
      54 A(J) = 1: PRINT J, A(J): A(J + 1) = 0:
      56 PRINT J + 1, A(J + 1): M = J + 1: J = 100
      58 ELSE
      60 A(J) = 0: PRINT J, A(J): M = J: J = 100
      62 END IF
      64 ELSE
      66 IF A(J - 1) MOD 2 = 1 THEN
      68 A(J) = A(J - 2) / 2
      70 ELSE
      72 A(J) = (A(J - 2) + 1) / 2
      74 END IF
      76 A(J + 1) = A(J) - 1: PRINT J, A(J): PRINT J + 1, A(J + 1)
      78 END IF
      80 NEXT J
      82 PRINT
      84 DIM T(3)
      86 T(0) = 2: T(1) = 3: T(2) = (T(1) ^ 2 - 2) MOD N
      88 IF T(2) = 0 THEN T(2) = T(2) + N
      90 FOR I = 0 TO 2: PRINT M - I, I, T(I): NEXT I
      100 K = 0
      102 FOR L = M - 3 TO 0 STEP -1
      104 IF A(L) MOD 2 = 1 THEN
      106 IF A(L) = A(L + 1) + A(L + 2) THEN K = 0 ELSE K = 1
      108 T(3) = (T(2 - K) * T(1 - K) - 3) MOD N
      110 ELSE
      112 T(3) = (T(1) ^ 2 - 2) MOD N
      114 END IF
      116 IF T(3) = 0 THEN T(3) = T(3) + N
      117 PRINT L, A(L), T(3)
      118 Z = T(2) MOD 2
      119 T(0) = T(1): T(1) = T(2): T(2) = T(3)
      120 NEXT L
      122 IF Z = 1 AND T(3) = 3 THEN
      124 PRINT "The number", N, " is prime."
      126 ELSE
      128 PRINT "The number", N, " is composite."
      130 END IF
      132 SLEEP 5: GOTO 38

      Bill B.
    Your message has been successfully submitted and would be delivered to recipients shortly.