Pell's equation: Difference between revisions

→‎{{header|langur}}: format number string with commas
(→‎{{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 = 17663190491,766,319,049
y = 226153980226,153,980
 
x² - 109y² = 1 for:
x = 158070671986249158,070,671,986,249
y = 1514042445510015,140,424,455,100
 
x² - 181y² = 1 for:
x = 2,469,645,423,824,185,801
x = 2469645423824185801
y = 183,567,298,683,461,940
y = 183567298683461940
 
x² - 277y² = 1 for:
x = 159,150,073,798,980,475,849
x = 159150073798980475849
y = 9,562,401,173,878,027,020
y = 9562401173878027020
 
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
x = 2565007112872132129669406439503954211359492684749762901360167370740763715001557789090674216330243703833040774221628256858633287876949448689668281446637464359482677366420261407112316649010675881349744201
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
y = 27126610172119035540864542981075550089190381938849116323732855930990771728447597698969628164719475714805646913222890277024408337458564351161990641948210581361708373955113191451102494265278824127994180
</pre>
 
885

edits