Amicable pairs: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add 8086 assembly |
m →{{header|REXX}}: added highlighting to some REXX preambles. |
||
Line 4,255: | Line 4,255: | ||
<br>also incorporates the search of amicable numbers into the generation of the sigmas of the integers. |
<br>also incorporates the search of amicable numbers into the generation of the sigmas of the integers. |
||
The optimization makes it about another '''30%''' faster when searching for amicable numbers up to one million. |
The optimization makes it about <u>another</u> '''30%''' faster when searching for amicable numbers up to one million. |
||
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
||
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |
||
Line 4,292: | Line 4,292: | ||
<br>computing the square of '''J''' to see if that value exceeds '''X'''). |
<br>computing the square of '''J''' to see if that value exceeds '''X'''). |
||
The optimization makes it about another '''20%''' faster when searching for amicable numbers up to one million. |
The optimization makes it about <u>another</u> '''20%''' faster when searching for amicable numbers up to one million. |
||
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
||
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |
||
Line 4,335: | Line 4,335: | ||
This method of coding has the disadvantage in that the code (logic) is less idiomatic and therefore less readable. |
This method of coding has the disadvantage in that the code (logic) is less idiomatic and therefore less readable. |
||
The optimization makes it about another '''15%''' faster when searching for amicable numbers up to one million. |
The optimization makes it about <u>another</u> '''15%''' faster when searching for amicable numbers up to one million. |
||
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
<lang rexx>/*REXX program calculates and displays all amicable pairs up to a given number. */ |
||
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |
parse arg H .; if H=='' | H=="," then H=20000 /*get optional arguments (high limit).*/ |