Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,39 @@
function HarmonicNumber(N: integer): double;
{Calculate sum of }
var I: integer;
begin
Result:=0;
for I:=1 to N do Result:=Result+1/I;
end;
function FirstHarmonicOver(Limit: integer): integer;
{Find first harmonic number over limit}
var HN: double;
begin
for Result:=1 to high(Integer) do
begin
HN:=HarmonicNumber(Result);
if HN>Limit then exit;
end
end;
procedure ShowHarmonicNumbers(Memo: TMemo);
var I,Inx: integer;
var HN: double;
begin
{Show first 20 harmonic numbers}
for I:=1 to 20 do
begin
HN:=HarmonicNumber(I);
Memo.Lines.Add(Format('%2D: %8.8f',[I,HN]));
end;
{Show the position of the number that exceeds 1..10 }
for I:=1 to 10 do
begin
Inx:=FirstHarmonicOver(I);
Memo.Lines.Add(Format('Position of the first harmonic number > %2D: %4D',[I,Inx]))
end;
end;