Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions
Content added Content deleted
(New post.) |
(add RPL) |
||
Line 1,345: | Line 1,345: | ||
<pre> 15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 |
<pre> 15,317 59,177 83,731 119,911 183,347 192,413 1,819,231 2,111,317 2,237,411 3,129,361 |
||
5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827</pre> |
5,526,173 11,610,313 13,436,683 13,731,373 13,737,841 13,831,103 15,813,251 17,692,313 19,173,071 28,118,827</pre> |
||
=={{header|RPL}}== |
|||
{{works with|HP|49}} |
|||
≪ '''IF''' DUP ISPRIME? '''THEN''' DROP <span style="color:red">0</span> '''ELSE''' |
|||
DUP FACTORS DUP SIZE |
|||
ROT →STR → n |
|||
≪ { } |
|||
<span style="color:red">1</span> ROT '''FOR''' j |
|||
OVER j GET →STR + <span style="color:grey">@ extract prime factors and convert into strings</span> |
|||
<span style="color:red">2</span> '''STEP''' NIP |
|||
≪ n SWAP POS ≫ MAP <span style="color:red">1</span> + ΠLIST <span style="color:grey">@ + 1 to avoid arror with singletons</span> |
|||
≫ |
|||
'''END''' |
|||
≫ '<span style="color:blue">MATRIOSHKA?</span>' STO |
|||
≪ { } |
|||
<span style="color:red">11 </span>MAXR EVAL '''FOR''' j |
|||
'''IF''' <span style="color:red">{ 3 5 7 }</span> ≪ j SWAP MOD ≫ MAP ΠLIST '''THEN''' <span style="color:grey">@ if no single digit factor</span> |
|||
'''IF''' j R→I <span style="color:blue">MATRIOSHKA?</span> '''THEN''' |
|||
j + |
|||
'''IF''' DUP SIZE <span style="color:red">6</span> == '''THEN''' MAXR EVAL 'j' STO '''END''' |
|||
'''END''' |
|||
'''END''' |
|||
<span style="color:red">2</span> '''STEP''' |
|||
≫ '<span style="color:blue">TASK</span>' STO |
|||
{{out}} |
|||
<pre> |
|||
1: {15317. 59177. 83731. 119911. 183347. 192413.} |
|||
</pre> |
|||
Finding the first 6 numbers takes 6 minutes 52 seconds on a iOS HP-49 emulator, meaning that more than two hours would be required to get ten. We're gonna need a bigger boat. |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |