Brunsche Konstante Turbo Pascal

aus Paswiki Turbo Pascal, der freien Wissensdatenbank

Beschreibung

Dieses Programm rechnet für Sie die Brunsche Konstante aus.


Die Brunsche Konstante ist die Summe des Kehrwerstes aller Primzahlzwillilnge.


Die genauste Schätzung liegt derzeit bei etwa 1.90...

Bei einem Durchlauf bis 500 Mio (dauert etliche Stunden) ist die Konstante ca. 1.77... groß.

Programm

{$N+}
program primzahlen; {von Fabian Reuter 27. Febr. 06}
uses crt,dos,Strings;
var   n,zahl,treffer,count,brun,x:longint;
time,time2:real;
 h1,m1,s1,s1001,h2,m2,s3,s1002:word;
 anzahl,vonanzahl: longint;
 brunconst:extended;

begin
brun:=6666;
writeln('Brunsche Konstante');
writeln('ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ');

writeln('bis zu welcher Zahl ?');
writeln;
readln(anzahl);
x:=1;
gettime(h1,m1,s1,s1001);

time:=60*m1+s1+((1/1000)*s1001);
if vonanzahl<3 then vonanzahl:=2;

for zahl:=1 to anzahl do
begin

treffer:=0;
if zahl=x*1000000 then   {bei jeder mio wird die Konstante geschrieben}
begin
x:=x+1;
writeln(brunconst:0:20);
end;

if not odd(zahl) and (zahl>2) then begin treffer:=1;end
else begin

for n:=3 to round(sqrt(zahl)) do
begin

if odd(n) then begin

if (zahl mod n =0) then begin treffer:=11;break;end;
end;

end;

end;

if (treffer=0)  then
begin
 count:=count+1;
if (zahl-brun=2) and (brun<>0) then

begin

 brunconst:=brunconst+((1/brun)+(1/zahl));
end;

brun:=zahl;
end;

end;

gettime(h2,m2,s3,s1002);

time2:=60*m2+s3+((1/1000)*s1002);

writeln;
writeln('Zeit : ',(time2-time):5:2,' Sekunden mit ', count,' Primzahlen');
writeln;
writeln('Brunsche Konstante = ',brunconst:0:15);

readln;
end.


--Gastarbeiter 16:58, 13. Mär 2006 (CET)


'Persönliche Werkzeuge
Extras