Pell's equation: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added commas to the huge numbers, simplified the SAY expressions for the output of X and Y.) |
m (→{{header|REXX}}: aligned some statements.) |
||
Line 968: | Line 968: | ||
if $=='' | $=="," then $= 61 109 181 277 /*Not specified? Then use the defaults*/ |
if $=='' | $=="," then $= 61 109 181 277 /*Not specified? Then use the defaults*/ |
||
d= 28 /*used for aligning the output numbers.*/ |
d= 28 /*used for aligning the output numbers.*/ |
||
do j=1 for words($); #= word($, j) |
do j=1 for words($); #= word($, j) /*process all the numbers in the list. */ |
||
parse value pells(#) with x y |
parse value pells(#) with x y /*extract the two values of X and Y.*/ |
||
cx= comma(x); Lcx= length(cx); cy= comma(y); |
cx= comma(x); Lcx= length(cx); cy= comma(y); Lcy= length(cy) |
||
say 'x^2 -'right(#, max(4, |
say 'x^2 -'right(#, max(4, length(#))) "* y^2 == 1" , |
||
' when x='right(cx, max(d, Lcx)) " and y="right(cy, max(d, Lcy)) |
|||
end /*j*/ |
end /*j*/ |
||
exit 0 /*stick a fork in it, we're all done. */ |
exit 0 /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |