Jacobi symbol: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added the REXX computer programming language for this task.)
m (→‎{{header|REXX}}: simplified code, aligned some statements, added comments.)
Line 253:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
hdrs: @.1= 'n/a ║'; do c=0 to cols; @.1= @.1 || right(c, 3)" "; end
L1L= length(@.1); !!= '╗'; @.1= left(@.1, L1L - 1) ; say @.1
@.2= '════╬'; do c=0 to cols; @.2= @.2 || "════╤" ; end
L2L= length(@.2); !!= '╗'; @.2= left(@.2, L2L - 1)"╗" ; say @.2
!!= '╝'; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
jacobi: procedure; parse arg a,n; er= '***error***'; result = 1
if n//2==0 then do; say '***error***er ' n " must be a positive odd integer."; exit 13
exit 13
end
a= a // n /*in REXX, // is modulus for non-neg A*/
result = 1
 
do while a\==0 /*perform while A isn't zero. */
Line 273 ⟶ 271:
end
 
parse value a n with n a with n a /*swap values of variables: A N */
if a//4==3 & n//4==3 then result= -result
a= a // n