Jump to content

AKS test for primes: Difference between revisions

(→‎{{header|Perl 6}}: use concat reduction instead of null join)
(→‎{{header|Ruby}}: Add output.)
Line 681:
 
=={{header|Ruby}}==
{{output?|Ruby}}
Using the `polynomial` Rubygem, this can be written directly from the definition in the description:
 
Line 726 ⟶ 725:
 
puts "\nPrimes below 50:", 50.times.select {|n| prime? n}.join(',')</lang>
 
{{output?|Ruby}}
<pre>(x-1)^0 = 1
(x-1)^1 = -1 + x
(x-1)^2 = 1 - 2*x + x**2
(x-1)^3 = -1 + 3*x - 3*x**2 + x**3
(x-1)^4 = 1 - 4*x + 6*x**2 - 4*x**3 + x**4
(x-1)^5 = -1 + 5*x - 10*x**2 + 10*x**3 - 5*x**4 + x**5
(x-1)^6 = 1 - 6*x + 15*x**2 - 20*x**3 + 15*x**4 - 6*x**5 + x**6
 
Primes below 50:
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47</pre>
 
=={{header|Rust}}==
1,481

edits

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