Pell's equation: Difference between revisions
→{{header|langur}}: format number string with commas
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) (→{{header|langur}}: format number string with commas) |
||
Line 680:
if .a^2 - .n x .b^2 == 1: return [.a, .b]
}
}
val .C = f(.x) {
# format number string with commas
var .neg, .s = ZLS, toString .x
if .s[1] == '-' {
.s = .s[2..len .s]
.neg = "-"
}
.neg ~ join ",", split -3, .s
}
for .n in [61, 109, 181, 277, 8941] {
val .x, .y = .solvePell(.n)
writeln $"x² - \.n;y² = 1 for:\n\tx = \.x:.C;\n\ty = \.y:.C;\n"
}
</lang>
Line 690 ⟶ 700:
{{out}}
<pre>x² - 61y² = 1 for:
x =
y =
x² - 109y² = 1 for:
x =
y =
x² - 181y² = 1 for:
x = 2,469,645,423,824,185,801
y = 183,567,298,683,461,940
x² - 277y² = 1 for:
x = 159,150,073,798,980,475,849
y = 9,562,401,173,878,027,020
x² - 8941y² = 1 for:
x = 2,565,007,112,872,132,129,669,406,439,503,954,211,359,492,684,749,762,901,360,167,370,740,763,715,001,557,789,090,674,216,330,243,703,833,040,774,221,628,256,858,633,287,876,949,448,689,668,281,446,637,464,359,482,677,366,420,261,407,112,316,649,010,675,881,349,744,201
y = 27,126,610,172,119,035,540,864,542,981,075,550,089,190,381,938,849,116,323,732,855,930,990,771,728,447,597,698,969,628,164,719,475,714,805,646,913,222,890,277,024,408,337,458,564,351,161,990,641,948,210,581,361,708,373,955,113,191,451,102,494,265,278,824,127,994,180
</pre>
|