Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
39
Task/Tau-function/Cowgol/tau-function.cowgol
Normal file
39
Task/Tau-function/Cowgol/tau-function.cowgol
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
typedef N is uint8;
|
||||
sub tau(n: N): (total: N) is
|
||||
total := 1;
|
||||
while n & 1 == 0 loop
|
||||
total := total + 1;
|
||||
n := n >> 1;
|
||||
end loop;
|
||||
var p: N := 3;
|
||||
while p*p <= n loop
|
||||
var count: N := 1;
|
||||
while n%p == 0 loop
|
||||
count := count + 1;
|
||||
n := n / p;
|
||||
end loop;
|
||||
total := total * count;
|
||||
p := p + 2;
|
||||
end loop;
|
||||
if n>1 then
|
||||
total := total << 1;
|
||||
end if;
|
||||
end sub;
|
||||
|
||||
sub print2(n: uint8) is
|
||||
print_char(' ');
|
||||
if n<10
|
||||
then print_char(' ');
|
||||
else print_i8(n/10);
|
||||
end if;
|
||||
print_i8(n%10);
|
||||
end sub;
|
||||
|
||||
var n: N := 1;
|
||||
while n <= 100 loop
|
||||
print2(tau(n));
|
||||
if n % 20 == 0 then print_nl(); end if;
|
||||
n := n + 1;
|
||||
end loop;
|
||||
Loading…
Add table
Add a link
Reference in a new issue