Sequence: smallest number with exactly n divisors: Difference between revisions

From Rosetta Code
Content added Content deleted
(Move Perl 6 entry from Anti-primes plus task)
m (Tidy heading)
Line 2: Line 2:


Calculate the sequence where each term <strong>a<sub>n</sub></strong> is the '''smallest natural numbers''' that has exactly '''n''' divisors.
Calculate the sequence where each term <strong>a<sub>n</sub></strong> is the '''smallest natural numbers''' that has exactly '''n''' divisors.

See: [[oeis:A005179|OEIS:A005179]]


;Task
;Task
Show here, on this page, at least the first 15 terms of the sequence.
Show here, on this page, at least the first '''15''' terms of the sequence.

;See also

:*[[oeis:A005179|OEIS:A005179]]

;Related tasks

:*[[Sequence: smallest number greater than previous term with exactly n divisors]]
:*[[Sequence: nth number with exactly n divisors‎‎]]


=={{header|Perl 6}}==
=={{header|Perl 6}}==

Revision as of 16:02, 11 April 2019

Sequence: smallest number with exactly n divisors is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Calculate the sequence where each term an is the smallest natural numbers that has exactly n divisors.

Task

Show here, on this page, at least the first 15 terms of the sequence.

See also
Related tasks

Perl 6

Works with: Rakudo version 2019.03

<lang perl6>sub div-count (\x) {

   return 2 if x.is-prime;
   +flat (1 .. x.sqrt.floor).map: -> \d {
       unless x % d { my \y = x div d; y == d ?? y !! (y, d) }
   }

}

my $limit = 15;

put "First $limit terms of OEIS:A005179"; put (1..$limit).map: -> $n { first { $n == .&div-count }, 1..Inf };

</lang>

Output:
First 15 terms of OEIS:A005179
1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144