Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Tau-function/Delphi/tau-function.delphi
Normal file
38
Task/Tau-function/Delphi/tau-function.delphi
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
program Tau_function;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
System.SysUtils;
|
||||
|
||||
function CountDivisors(n: Integer): Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
var i := 1;
|
||||
var k := 2;
|
||||
if (n mod 2) = 0 then
|
||||
k := 1;
|
||||
|
||||
while i * i <= n do
|
||||
begin
|
||||
if (n mod i) = 0 then
|
||||
begin
|
||||
inc(Result);
|
||||
var j := n div i;
|
||||
if j <> i then
|
||||
inc(Result);
|
||||
end;
|
||||
inc(i, k);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
writeln('The tau functions for the first 100 positive integers are:');
|
||||
for var i := 1 to 100 do
|
||||
begin
|
||||
write(CountDivisors(i): 2, ' ');
|
||||
if (i mod 20) = 0 then
|
||||
writeln;
|
||||
end;
|
||||
readln;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue