Jacobi symbol: Difference between revisions
Content added Content deleted
(Added Sidef) |
m (→{{header|REXX}}: added whitespace and comments.) |
||
Line 297: | Line 297: | ||
do r=1 by 2 to rows; _= right(r, 3) /*build odd (numbered) rows of a table.*/ |
do r=1 by 2 to rows; _= right(r, 3) /*build odd (numbered) rows of a table.*/ |
||
do c=0 to cols /* [↓] build a column for a table row.*/ |
do c=0 to cols /* [↓] build a column for a table row.*/ |
||
_= _ ! right(jacobi(c, r), 2); != '│' |
_= _ ! right(jacobi(c, r), 2); != '│' /*reset grid end char.*/ |
||
end /*c*/ |
end /*c*/ |
||
say _ '║'; != '║' /*display a table row; reset grid glyph*/ |
say _ '║'; != '║' /*display a table row; reset grid glyph*/ |
||
Line 305: | Line 305: | ||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
hdrs: @.1= 'n/a ║'; do c=0 to cols; @.1= @.1 || right(c, 3)" "; end |
hdrs: @.1= 'n/a ║'; do c=0 to cols; @.1= @.1 || right(c, 3)" "; end |
||
L= length(@.1); @.1= left(@.1, L - 1) |
L= length(@.1); @.1= left(@.1, L - 1) ; say @.1 |
||
@.2= '════╬'; do c=0 to cols; @.2= @.2 || "════╤" ; end |
@.2= '════╬'; do c=0 to cols; @.2= @.2 || "════╤" ; end |
||
L= length(@.2); @.2= left(@.2, L - 1)"╗" |
L= length(@.2); @.2= left(@.2, L - 1)"╗" ; say @.2 |
||
!= '║' ; return /*define an external grid border glyph.*/ |
!= '║' ; return /*define an external grid border glyph.*/ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Line 319: | Line 319: | ||
end /*while a//2==0*/ |
end /*while a//2==0*/ |
||
parse value a n with n a /*swap values of variables: A N */ |
parse value a n with n a /*swap values of variables: A N */ |
||
if a//4==3 & n//4==3 then $= -$ |
if a//4==3 & n//4==3 then $= -$ /* A mod 4, N mod 4. Both ≡ 3 ?*/ |
||
a= a // n |
a= a // n /*obtain A modulus N */ |
||
end /*while a\==0*/ |
end /*while a\==0*/ |
||
if n==1 then return $ |
if n==1 then return $ |