Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
No edit summary
Line 395: Line 395:
{{out}}
{{out}}
<pre>The first 32 anti-primes plus are: 1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624 4632 65536 65572 262144 262192 263169 269312 4194304 4194306 4477456 4493312 4498641 4498752 268435456 268437200 1073741824 1073741830 223 ms</pre>
<pre>The first 32 anti-primes plus are: 1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624 4632 65536 65572 262144 262192 263169 269312 4194304 4194306 4477456 4493312 4498641 4498752 268435456 268437200 1073741824 1073741830 223 ms</pre>

=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}


<syntaxhighlight lang="Delphi">


{These routines would normally be in a library, but the shown here for clarity}

function GetAllProperDivisors(N: Integer;var IA: TIntegerDynArray): integer;
{Make a list of all the "proper dividers" for N}
{Proper dividers are the of numbers the divide evenly into N}
var I: integer;
begin
SetLength(IA,0);
for I:=1 to N-1 do
if (N mod I)=0 then
begin
SetLength(IA,Length(IA)+1);
IA[High(IA)]:=I;
end;
Result:=Length(IA);
end;


function GetAllDivisors(N: Integer;var IA: TIntegerDynArray): integer;
{Make a list of all the "proper dividers" for N, Plus N itself}
begin
Result:=GetAllProperDivisors(N,IA)+1;
SetLength(IA,Length(IA)+1);
IA[High(IA)]:=N;
end;


procedure SmallestWithNDivisors(Memo: TMemo);
var N,Count: integer;
var IA: TIntegerDynArray;
begin
Count:=1;
for N:=1 to high(Integer) do
if Count=GetAllDivisors(N,IA) then
begin
Memo.Lines.Add(IntToStr(Count)+' - '+IntToStr(N));
Inc(Count);
if Count>15 then break;
end;
end;


</syntaxhighlight>
{{out}}
<pre>
1 - 1
2 - 2
3 - 4
4 - 6
5 - 16
6 - 18
7 - 64
8 - 66
9 - 100
10 - 112
11 - 1024
12 - 1035
13 - 4096
14 - 4288
15 - 4624

Elapsed Time: 58.590 ms.

</pre>



=={{header|Dyalect}}==
=={{header|Dyalect}}==