Proper divisors: Difference between revisions
→{{header|Factor}}: count divisors, don't store them
m (→JS ES6) |
(→{{header|Factor}}: count divisors, don't store them) |
||
Line 1,627:
=={{header|Factor}}==
<lang factor>USING: formatting io kernel math math.functions
10 [1,b] [ divisors but-last ] map [ 1 + pprint bl . ] each-index▼
: #divisors ( m -- n )
20000 [1,b] [ divisors but-last length ] map dup supremum▼
dup sqrt >integer 1 + [1,b] [ divisor? ] with count dup +
1 - ;
"%d with %d divisors.\n" printf</lang>
{{out}}
|