Count in factors: Difference between revisions

Added Quackery.
m (Changed type of “first" from integer to boolean.)
(Added Quackery.)
Line 3,426:
Number of primes gathered up to 5000 is 669
CacheInfo(hits=3935, misses=7930, maxsize=2000, currsize=2000)</pre>
 
 
=={{header|Quackery}}==
 
Reusing the code from [http://rosettacode.org/wiki/Prime_decomposition#Quackery Prime Decomposition].
 
<lang Quackery> [ [] swap
dup times
[ [ dup i^ 2 + /mod
0 = while
nip dip
[ i^ 2 + join ]
again ]
drop
dup 1 = if conclude ]
drop ] is primefactors ( n --> [ )
[ 1 dup echo cr
[ 1+ dup primefactors
witheach
[ echo
i if [ say " x " ] ]
cr again ] ] is countinfactors ( --> )
 
countinfactors</lang>
 
{{out}}
 
<pre>1
2
3
2 x 2
5
2 x 3
7
2 x 2 x 2
3 x 3
2 x 5
11
2 x 2 x 3
13
2 x 7
3 x 5
2 x 2 x 2 x 2
17
2 x 3 x 3
19
2 x 2 x 5
3 x 7
2 x 11
23</pre>
… and so on. Quackery uses bignums, so "… until boredom ensues."
 
=={{header|R}}==
1,462

edits