Jump to content

Strong and weak primes: Difference between revisions

m
→‎{{header|Pascal}}: changed indifferent into balanced
m (→‎{{header|Pascal}}: changed indifferent into balanced)
Line 212:
 
=={{header|Pascal}}==
Converting the primes into deltaPrime, so that its easy to check the strong- /weakness.
Startprime 2 +1 -> (3)+2-> (5)+2 ->(7) +4-> (11)+2 .... 1,2,2,4,2,4,2,4,6,2,....
By using only odd primes startprime is 3 and delta -> delta/2
If deltaAfter < deltaBefore than a strong prime is found.
<lang pascal>program WeakPrim;
{$IFNDEF FPC}
Line 228:
tWeakStrong = record
strong,
indifferentbalanced,
weak : NativeUint;
end;
Line 273:
}
function GetDeltas:NativeUint;
//Converting prime positions into distance
var
i,j,last : NativeInt;
Line 292 ⟶ 293:
procedure OutHeader;
Begin
writeln('Limit':12,'Strong':10,'indifferentbalanced':12,'weak':10);
end;
 
Line 298 ⟶ 299:
Begin
with cntWS do
writeln(lmt:12,Strong:10,indifferentbalanced:12,weak:10);
end;
 
procedure CntWeakStrong10(var Out:tWeakStrong);
// Output a table of values for strang/balanced/weak for 10^n
var
idx,diff,prime,lmt :NativeInt;
Line 325 ⟶ 327:
inc(Out.weak)
else
inc(Out.indifferentbalanced);
inc(idx);
Line 390 ⟶ 392:
The first 37 weak primes
3 7 13 19 23 31 43 47 61 73 83 89 103 109 113 131 139 151 167 181 193 199 229 233 241 271 283 293 313 317 337 349 353 359 383 389 401
Limit Strong indifferent balanced weak
10 0 1 2
100 10 2 12
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.