AKS test for primes: Difference between revisions

Content added Content deleted
(→‎{{header|Ruby}}: Add implementation.)
m (→‎{{header|REXX}}: show largest coefficient)
Line 623: Line 623:
limit=200
limit=200
pl=''
pl=''
mmm=0
Do p=3 To limit
Do p=3 To limit
pm1=p-1
pm1=p-1
Line 630: Line 631:
jm1=j-1
jm1=j-1
c.p.j=c.pm1.jm1+c.pm1.j
c.p.j=c.pm1.jm1+c.pm1.j
mmm=max(mmm,c.p.j)
End
End
End
End
Line 657: Line 659:
pl=pl (i-1)
pl=pl (i-1)
End
End
Say ' '
Say 'Primes:' subword(pl,2,27)
Say 'Primes:' subword(pl,2,27)
Say ' ' subword(pl,28) </lang>
Say ' ' subword(pl,28)
Say 'Largest coefficient:' mmm
Say 'This has' length(mmm) 'digits' </lang>
{{out}}
{{out}}
<pre>(x-1)**0 = 1
<pre>(x-1)**0 = 1
Line 669: Line 674:
(x-1)^7 = x^7 - 7*x^6 + 21*x^5 - 35*x^4 + 35*x^3 - 21*x^2 + 7*x - 1
(x-1)^7 = x^7 - 7*x^6 + 21*x^5 - 35*x^4 + 35*x^3 - 21*x^2 + 7*x - 1
(x-1)^8 = x^8 - 8*x^7 + 28*x^6 - 56*x^5 + 70*x^4 - 56*x^3 + 28*x^2 - 8*x + 1
(x-1)^8 = x^8 - 8*x^7 + 28*x^6 - 56*x^5 + 70*x^4 - 56*x^3 + 28*x^2 - 8*x + 1

Primes: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103
Primes: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103
103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 </pre>
103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199
Largest coefficient: 45274257328051640582702088538742081937252294837706668420660
This has 59 digits </pre>


=={{header|Ruby}}==
=={{header|Ruby}}==