Achilles numbers: Difference between revisions
Content added Content deleted
m (→{{header|RPL}}: add a few comments) |
(→{{header|RPL}}: Faster version) |
||
Line 2,779: | Line 2,779: | ||
Based on Wikipedia definition: n = p<sub>1</sub><sup>a<sub>1</sub></sup>p<sub>2</sub><sup>a<sub>2</sub></sup>…p<sub>k</sub><sup>a<sub>k</sub></sup> is an Achilles number if min(a<sub>1</sub>, a<sub>2</sub>, …, a<sub>k</sub>) ≥ 2 and gcd(a<sub>1</sub>, a<sub>2</sub>, …, a<sub>k</sub>) = 1. |
Based on Wikipedia definition: n = p<sub>1</sub><sup>a<sub>1</sub></sup>p<sub>2</sub><sup>a<sub>2</sub></sup>…p<sub>k</sub><sup>a<sub>k</sub></sup> is an Achilles number if min(a<sub>1</sub>, a<sub>2</sub>, …, a<sub>k</sub>) ≥ 2 and gcd(a<sub>1</sub>, a<sub>2</sub>, …, a<sub>k</sub>) = 1. |
||
{{works with|HP|49g}} |
{{works with|HP|49g}} |
||
≪ |
≪ FACTORS |
||
⚫ | |||
≪ { } DUP |
|||
⚫ | |||
⚫ | |||
≫ ≫ '<span style="color:blue">UNBUNDL</span>' STO |
|||
≪ DUP FACTORS |
|||
⚫ | |||
'''ELSE''' |
'''ELSE''' |
||
{ } 2 3 PICK SIZE '''FOR''' j <span style="color:grey">@ keeps exponents only</span> |
|||
⚫ | |||
≪ 1 p INV - ΠLIST →NUM * <span style="color:grey">@ get phi(n)</span> |
|||
⚫ | |||
⚫ | |||
→ a |
|||
⚫ | |||
AND * <span style="color:grey">@ if Achilles, returns phi(n))</span> |
|||
≫ |
≫ |
||
'''END''' |
'''END''' |
||
Line 2,805: | Line 2,799: | ||
≪ { } 1 → n |
≪ { } 1 → n |
||
≪ '''WHILE''' DUP SIZE 20 < '''REPEAT''' |
≪ '''WHILE''' DUP SIZE 20 < '''REPEAT''' |
||
'''IF''' 'n' INCR <span style="color:blue">ACH?</span> |
'''IF''' 'n' INCR <span style="color:blue">ACH?</span> |
||
'''THEN''' IF n EULER <span style="color:blue">ACH?</span> '''THEN''' n + '''END END''' |
|||
'''END''' |
'''END''' |
||
≫ ≫ EVAL |
≫ ≫ EVAL |
||
Line 2,813: | Line 2,808: | ||
1: {500 864 1944 2000 2592 3456 5000 10125 10368 12348 12500 16875 19652 19773 30375 31104 32000 33275 37044 40500} |
1: {500 864 1944 2000 2592 3456 5000 10125 10368 12348 12500 16875 19652 19773 30375 31104 32000 33275 37044 40500} |
||
</pre> |
</pre> |
||
First 50 Achilles numbers found in |
First 50 Achilles numbers found in 53 seconds on the ''iHP48'' emulator running on a iPhone Xr; first 20 strong Achilles numbers found in 5 minutes 13 seconds on the same platform. |
||
=={{header|Rust}}== |
=={{header|Rust}}== |