Anti-primes: Difference between revisions
Content deleted Content added
+Racket |
|||
Line 1,286:
{{out}}
<pre> [1] 1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560</pre>
=={{header|Racket}}==
<lang racket>#lang racket
(require racket/generator
math/number-theory)
(define (get-divisors n)
(apply * (map (λ (factor) (add1 (second factor))) (factorize n))))
(define antiprimes
(in-generator
(for/fold ([prev 0]) ([i (in-naturals 1)])
(define divisors (get-divisors i))
(when (> divisors prev) (yield i))
(max prev divisors))))
(for/list ([i (in-range 20)] [antiprime antiprimes]) antiprime)</lang>
{{out}}
<pre>
'(1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560)
</pre>
=={{header|REXX}}==
|