Anonymous user
Square-free integers: Difference between revisions
m
→{{header|REXX}}: changed whitespace and comments, changed some variable names, used the correct glyph for a logical not.
Catskill549 (talk | contribs) |
m (→{{header|REXX}}: changed whitespace and comments, changed some variable names, used the correct glyph for a logical not.) |
||
Line 1,618:
if HI=='' | HI=="," then HI= 145 /* " " " " " " */
sw= linesize() - 1 /*use one less than a full line. */
$= /*variable that holds a line of numbers*/
do j=LO to abs(HI) /*process all integers between LO & HI.*/
if \isSquareFree(j) then iterate /*Not square─free? Then skip this #. */
if HI<0 then iterate /*Only counting 'em? Then look for more*/
if length($ || j)<sw then $= strip($ j) /*append the number to the output list.*/
Line 1,629:
if $\=='' then say $ /*are there any residuals to display ? */
if HI<0 then say
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
isSquareFree: procedure; parse arg
odd=
do k=2+odd to iSqrt(
if
end /*k*/ /* [↑] Yes? Then
return 1 /* [↑] // is REXX's ÷ remainder.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
iSqrt: procedure; parse arg x; q= 1; do while q<=x; q= q * 4
r= 0
do while q>1; q= q % 4; _= x - r - q; r= r % 2
if _>=0 then do; x= _; r= r + q; end
end /*while q>1*/
return r /*R is the integer square root of X. */</lang>
|