Tau number: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Draco) |
Not a robot (talk | contribs) (Add CLU) |
||
Line 597: | Line 597: | ||
972 996 1016 1040 1044 1048 1056 1068 1089 1096 |
972 996 1016 1040 1044 1048 1056 1068 1089 1096 |
||
</pre> |
</pre> |
||
=={{header|CLU}}== |
|||
<lang clu>% Count the divisors of [1..N] |
|||
count_divisors = proc (n: int) returns (sequence[int]) |
|||
divs: array[int] := array[int]$fill(1, n, 1) |
|||
for i: int in int$from_to(2, n) do |
|||
for j: int in int$from_to_by(i, n, i) do |
|||
divs[j] := divs[j] + 1 |
|||
end |
|||
end |
|||
return(sequence[int]$a2s(divs)) |
|||
end count_divisors |
|||
% Find Tau numbers up to a given limit |
|||
tau_numbers = iter (lim: int) yields (int) |
|||
divs: sequence[int] := count_divisors(lim) |
|||
n: int := 0 |
|||
while n < lim do |
|||
n := n + 1 |
|||
if n // divs[n] = 0 then yield(n) end |
|||
end |
|||
end tau_numbers |
|||
% Show the first 100 Tau numbers |
|||
start_up = proc () |
|||
po: stream := stream$primary_output() |
|||
seen: int := 0 |
|||
for n: int in tau_numbers(1100) do |
|||
seen := seen + 1 |
|||
stream$putright(po, int$unparse(n), 5) |
|||
if seen // 10 = 0 then stream$putl(po, "") end |
|||
if seen >= 100 then break end |
|||
end |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre> 1 2 8 9 12 18 24 36 40 56 |
|||
60 72 80 84 88 96 104 108 128 132 |
|||
136 152 156 180 184 204 225 228 232 240 |
|||
248 252 276 288 296 328 344 348 360 372 |
|||
376 384 396 424 441 444 448 450 468 472 |
|||
480 488 492 504 516 536 560 564 568 584 |
|||
600 612 625 632 636 640 664 672 684 708 |
|||
712 720 732 776 792 804 808 824 828 852 |
|||
856 864 872 876 880 882 896 904 936 948 |
|||
972 996 1016 1040 1044 1048 1056 1068 1089 1096</pre> |
|||
=={{header|Cowgol}}== |
=={{header|Cowgol}}== |
||
Line 646: | Line 692: | ||
856 864 872 876 880 882 896 904 936 948 |
856 864 872 876 880 882 896 904 936 948 |
||
972 996 1016 1040 1044 1048 1056 1068 1089 1096</pre> |
972 996 1016 1040 1044 1048 1056 1068 1089 1096</pre> |
||
=={{header|D}}== |
=={{header|D}}== |