AKS test for primes: Difference between revisions

Content deleted Content added
Markjreed (talk | contribs)
m →‎{{header|Ruby}}: don't need to_s inside #{}
Markjreed (talk | contribs)
→‎{{header|Ruby}}: make output match
Line 695: Line 695:


7.times do |n|
7.times do |n|
puts "(x-1)^#{n} = #{x_minus_1_to_the(n)}"
puts "(x-1)^#{n} = #{x_minus_1_to_the(n).to_s.gsub(/\*\*/,'^').gsub(/\*/,'')}"
end
end


Line 729: Line 729:
<pre>(x-1)^0 = 1
<pre>(x-1)^0 = 1
(x-1)^1 = -1 + x
(x-1)^1 = -1 + x
(x-1)^2 = 1 - 2*x + x**2
(x-1)^2 = 1 - 2x + x^2
(x-1)^3 = -1 + 3*x - 3*x**2 + x**3
(x-1)^3 = -1 + 3x - 3x^2 + x^3
(x-1)^4 = 1 - 4*x + 6*x**2 - 4*x**3 + x**4
(x-1)^4 = 1 - 4x + 6x^2 - 4x^3 + x^4
(x-1)^5 = -1 + 5*x - 10*x**2 + 10*x**3 - 5*x**4 + x**5
(x-1)^5 = -1 + 5x - 10x^2 + 10x^3 - 5x^4 + x^5
(x-1)^6 = 1 - 6*x + 15*x**2 - 20*x**3 + 15*x**4 - 6*x**5 + x**6
(x-1)^6 = 1 - 6x + 15x^2 - 20x^3 + 15x^4 - 6x^5 + x^6


Primes below 50:
Primes below 50: