Aliquot sequence classifications: Difference between revisions
Content added Content deleted
(J solution) |
m (→{{header|J}}) |
||
Line 114: | Line 114: | ||
aliquot =: [: +/ proper_divisors ::0: |
aliquot =: [: +/ proper_divisors ::0: |
||
rc_aliquot_sequence =: aliquot^:(i.16)&> |
rc_aliquot_sequence =: aliquot^:(i.16)&> |
||
rc_classify =: [: {. ([;.1' terminate non-terminating perfect amicable sociable aspiring cyclic') #~ (6 > {:) , (([: +./ (2^47x)&<) +. (16 = #@:~.)) , (1 = #@:~.) , ((8&= , 1&<)@:{.@:(#/.~)) , ([: =/ _2&{.) , 1: |
|||
rc_classify =: 3 : 0 |
|||
⚫ | |||
assert 16 = # y |
|||
if. 6 > {: y do. 'terminate' return. end. NB. sequence ends in 0--5, strictly test for 0 only, but seriously... |
|||
COUNTS =: (#,{.)/.~ y |
|||
if. (+./ (2^47x) < y) +. 16 = # COUNTS do. 'non-terminating' return. end. |
|||
if. 1 = # COUNTS do. 'perfect' return. end. |
|||
if. 8 = (<0 0) { COUNTS do. 'amicable' return. end. |
|||
if. 1 < (<0 0) { COUNTS do. 'sociable' return. end. |
|||
if. =/ _2 {. y do. 'aspiring' return. end. |
|||
'cyclic' |
|||
) |
|||
⚫ | |||
</lang> |
</lang> |
||
<lang J> |
<lang J> |
||
rc_display_aliquot_sequence&>>:i.10 |
rc_display_aliquot_sequence&> >: i.10 |
||
terminate 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 4 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
perfect 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 |
|||
terminate 7 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 8 7 1 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 9 4 3 1 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
terminate 10 8 7 1 0 0 0 0 0 0 0 0 0 0 0 0 |
|||
rc_display_aliquot_sequence&>11, 12, 28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080x |
rc_display_aliquot_sequence&>11, 12, 28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080x |
||
terminate 11 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
|||
terminate 12 16 15 9 4 3 1 0 0 0 0 0 0 0 0 0 ... |
|||
perfect 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 ... |
|||
perfect 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 ... |
|||
amicable 220 284 220 284 220 284 220 284 220 284 220 284 220 284 220 284 ... |
|||
amicable 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 ... |
|||
sociable 12496 14288 15472 14536 14264 12496 14288 15472 14536 14264 12496 14288 15472 14536 14264 12496 ... |
|||
sociable 1264460 1547860 1727636 1305184 1264460 1547860 1727636 1305184 1264460 1547860 1727636 1305184 1264460 1547860 1727636 1305184 ... |
|||
aspiring 790 650 652 496 496 496 496 496 496 496 496 496 496 496 496 496 ... |
|||
aspiring 909 417 143 25 6 6 6 6 6 6 6 6 6 6 6 6 ... |
|||
cyclic 562 284 220 284 220 284 220 284 220 284 220 284 220 284 220 284 ... |
|||
cyclic 1064 1336 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 1184 1210 ... |
|||
non-terminating 1488 2480 3472 4464 8432 9424 10416 21328 22320 55056 95728 96720 236592 459792 881392 882384 |
non-terminating 1488 2480 3472 4464 8432 9424 10416 21328 22320 55056 95728 96720 236592 459792 881392 882384 ... |
||
non-terminating 15355717786080 44534663601120 144940087464480 471714103310688 1130798979186912 2688948041357088 6050151708497568 13613157922639968 35513546724070632 74727605255142168 162658586225561832 353930992506879768 642678347124409032 |
non-terminating 15355717786080 44534663601120 144940087464480 471714103310688 1130798979186912 2688948041357088 6050151708497568 13613157922639968 35513546724070632 74727605255142168 162658586225561832 353930992506879768 642678347124409032 112510261154846... |
||
</lang> |
</lang> |
||