Arithmetic numbers: Difference between revisions
Content added Content deleted
m (J: bugfix -- 1 is not composite) |
m (→{{header|J}}: example goes in example section, also it's faster to not test numbers larger than a million) |
||
Line 84: | Line 84: | ||
<lang J>factors=: {{ */@>,{(^ [:i.1+])&.>/__ q:y}} |
<lang J>factors=: {{ */@>,{(^ [:i.1+])&.>/__ q:y}} |
||
isArith=: {{ (= <.) (+/%#) factors y}}"0 |
isArith=: {{ (= <.) (+/%#) factors y}}"0</lang> |
||
example=: >:I.isArith>:i.2e6</lang> |
|||
Task examples: |
Task examples: |
||
<lang J> |
<lang J>example=: >:I.isArith>:i.1e6 |
||
10 10$example |
|||
1 3 5 6 7 11 13 14 15 17 |
1 3 5 6 7 11 13 14 15 17 |
||
19 20 21 22 23 27 29 30 31 33 |
19 20 21 22 23 27 29 30 31 33 |