Anonymous user
Largest proper divisor of n: Difference between revisions
→{{header|REXX}}: added logic to a function to only use odd divisors for odd numbers.
(Realize in F#) |
(→{{header|REXX}}: added logic to a function to only use odd divisors for odd numbers.) |
||
Line 746:
=={{header|REXX}}==
Logic was added to the '''LPDIV''' function so that for odd numbers, only odd divisors were used.
This addition made it about '''75%''' faster.
<lang rexx>/*REXX program finds the largest proper divisors of all numbers (up to a given limit). */
parse arg n cols . /*obtain optional argument from the CL.*/
Line 767 ⟶ 770:
/*──────────────────────────────────────────────────────────────────────────────────────*/
LPDIV: procedure; parse arg x; if x<4 then return 1 /*obtain X; test if X < 4. */
odd= x // 2;
if odd
if x//k==0
end /*k*/
return 1 /*If we get here, then X is a prime.*/</lang>
{{out|output|text= when using the default inputs:}}
<pre>
|