Count in factors: Difference between revisions

Content deleted Content added
→‎{{header|Perl 6}}: A more symbolic implementation; factors are returned as an array, and formatted by the caller to factor().
add J
Line 2:
 
For examle, <math>2</math> is prime, so it would be shown as itself. <math>6</math> is not prime; it would be shown as <math>2\times3</math>. Likewise, 2144 is not prime; it would be shown as <math>2\times2\times2\times2\times2\times67</math>.
 
=={{header|J}}==
 
'''Solution''':Use J's factoring primitive, <lang j>q:</lang>
'''Example''' (including formatting):<lang j> ('1 : 1',":&> ,"1 ': ',"1 ":@q:) 2+i.10
1 : 1
2 : 2
3 : 3
4 : 2 2
5 : 5
6 : 2 3
7 : 7
8 : 2 2 2
9 : 3 3
10: 2 5
11: 11</lang>
 
=={{header|Perl 6}}==