Greatest prime dividing the n-th cubefree number: Difference between revisions
Greatest prime dividing the n-th cubefree number (view source)
Revision as of 07:56, 8 March 2024
, 3 months ago→resursive alternative: Using Apéry's Constant
(→{{header|Free Pascal}}: added recursive version, but only to check.Not tryinge to the limit for cnt = 10^n) |
m (→resursive alternative: Using Apéry's Constant) |
||
Line 471:
</pre>
===resursive alternative===
only counting til limit.
<syntaxhighlight lang="pascal">
program CubeFree3;
Line 485:
;
const
//Apéry's Constant
Z3 = 1.20205690315959428539973816151144999;
RezZ3 = 0.831907372580707468683126278821530734417;
{
limits :array[0..9] of UInt64 =
(1199,12019,120203,1202057,12020570,120205685,1202056919,
12020569022,120205690298,1202056903137);
}
type
tPrimeIdx = 0..192724;// primes til 2,642,246 ^3 ~ 2^64-1= High(Uint64)
Line 579 ⟶ 585:
end;
procedure OutNum(lmt,n,CntDivs:Uint64);
begin
writeln(Numb2Usa(lmt):26,'|',Numb2Usa(n):26,'|',Numb2Usa(CntDivs):10);
end;
var
CntDivs : Uint32;
procedure check(lmt:Uint64;i:integer;flip :Boolean);
Line 593 ⟶ 600:
For i := i to high(tPrimeIdx) do
begin
p :=
if
BREAK;
inc(CntDivs);
p := lmt DIV p;
if flip then
cnt -= p
Line 606 ⟶ 615:
procedure Checklmt(lmtIdx:Uint32);
var
limit : extended;
lmt: Uint64;
begin
limit := Z3;
Begin
▲ while LmtIdx> High(Limits) do
▲ dec(LmtIdx);
end▼
cnt := lmt;
CntDivs := 0;
check(lmt,0,true);
OutNum(lmt,cnt,CntDivs);
end;
Line 627 ⟶ 636:
i : integer;
Begin
T0 := GetTickCount64;▼
InitSmallPrimes;
InitDelCube(DelCube);
writeln('Limit | cube free numbers |count of divisions');
▲ T0 := GetTickCount64;
For i := 0 to 18 do
Checklmt(i);
T0 := GetTickCount64-T0;
writeln(' runtime ',T0/1000:0:3,' s');
{{out|@home}}
<pre>
Limit
120,205,690,315,959| 100,000,000,000,027| 30,006
1,202,056,903,159,594| 1,000,000,000,000,087| 64,643
12,020,569,031,595,942| 9,999,999,999,999,948| 139,261
120,205,690,315,959,428| 100,000,000,000,000,094| 300,023
1,202,056,903,159,594,285| 1,000,000,000,000,000,317| 646,394
runtime 0.002 s
</pre>
|