Jump to content

Arithmetic numbers: Difference between revisions

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

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.