Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Tau-number/CLU/tau-number.clu
Normal file
33
Task/Tau-number/CLU/tau-number.clu
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
% 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue