Jump to content

AKS test for primes: Difference between revisions

m
→‎{{header|REXX}}: show largest coefficient
(→‎{{header|Ruby}}: Add implementation.)
m (→‎{{header|REXX}}: show largest coefficient)
Line 623:
limit=200
pl=''
mmm=0
Do p=3 To limit
pm1=p-1
Line 630 ⟶ 631:
jm1=j-1
c.p.j=c.pm1.jm1+c.pm1.j
mmm=max(mmm,c.p.j)
End
End
Line 657 ⟶ 659:
pl=pl (i-1)
End
Say ' '
Say 'Primes:' subword(pl,2,27)
Say ' ' subword(pl,28) </lang>
Say 'Largest coefficient:' mmm
Say 'This has' length(mmm) 'digits' </lang>
{{out}}
<pre>(x-1)**0 = 1
Line 669 ⟶ 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)^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
103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 </pre>
Largest coefficient: 45274257328051640582702088538742081937252294837706668420660
This has 59 digits </pre>
 
=={{header|Ruby}}==
2,300

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.