Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions
Sequence: smallest number greater than previous term with exactly n divisors (view source)
Revision as of 17:55, 10 April 2019
, 5 years ago→{{header|Perl 6}}: various tweaks, expand last sequence to 15 terms
m (→{{header|Pascal}}: typo) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: various tweaks, expand last sequence to 15 terms) |
||
Line 383:
This task could be interpreted in a few ways.
Could be the sequence of the '''smallest natural numbers''' such that each <strong>a<sub>n</sub></strong> has '''n''' divisors: [[oeis:A005179|OEIS:
Or, could be the sequence where each term <strong>a<sub>n</sub></strong> is the <strong>smallest natural number > a<sub>n-1</sub></strong> that has '''n''' divisors: [[oeis:A069654|OEIS:
Or, it could be something else entirely.
Line 398:
}
my $limit = 15;
put 'First 15 terms of OEIS: A005179';▼
put (1..15).map: -> $n { first { $n == .&div-count }, 1..Inf };▼
my $m = 1;
put "\nFirst
put (1..
# Actually, since there is no verbiage in the task description about
# choosing the _smallest_ integer, for each term, this complies with
# a strict interpretation of the requirements.
put "\nTechnically correct is the best kind of correct:";▼
my $antipp = (1..5000).race.classify: { .&div-count };
▲put "\nTechnically correct is the best kind of correct:";
put (1..
# Oooo! Here's a good one. Each term is the nth occurrence of an integer with
# n divisors. Limit to 10 terms as this gets pretty intensive pretty quickly.
my @primes = grep { .is-prime }, 1..*;
@primes[$limit]; # prime the array. SCNR
put "\nNth occurrence of an integer with n divisors:";
put (1..
next unless $
next unless ++$i == $n;
$_
}
}
};</lang>
{{out}}
<pre>First 15 terms of OEIS:
1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144
First 15 terms of OEIS:
1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624
Technically correct is the best kind of correct:
1
Nth occurrence of an integer with n divisors:
1 3 25 14 14641 44 24137569 70 1089 405 819628286980801 160 22563490300366186081 2752 9801</pre>
=={{header|REXX}}==
|