Category:PrimTrial: Difference between revisions

m
changed check for small primes in SmallFactor via Bit Mask 2..61
m (changed <lang into <syntaxhighlight)
m (changed check for small primes in SmallFactor via Bit Mask 2..61)
Line 2:
{{works with|Free Pascal}} {{works with|Delphi}}
Maybe NativeUint must be typed in older versions to LongWord aka cardinal
<syntaxhighlight lang="pascal">unit primTrialPrimTrial;
// NativeUInt: LongWord 32-Bit-OS/ Uint64 64-Bit-OS
{$IFDEF FPC}
{$MODE DELPHI}
{$Smartlink ON}
{$OPTIMIZATION ON,Regvar,PEEPHOLE,CSE,ASMCSEALL}
{$CODEALIGN proc=32}
{$ENDIF}
Line 111:
function SmallFactor(pr: NativeUint):NativeUint;
//checking numbers omitted by biggerFactor
const
// Bit Mask for small primes
Check2_61 :UInt64 = 1 shl 2+1 shl 3+1 shl 5+1 shl 7+1 shl 11+1 shl 13+1 shl 17+
1 shl 19+1 shl 23+1 shl 29+1 shl 31+1 shl 37+1 shl 41+1 shl 47+
1 shl 51+1 shl 57+1 shl 59+1 shl 61;
var
k : NativeUint;
Begin
result := pr;
IFif pr in< [2,3,5,7,11,13]64 then
if (Uint64(1) shl pr) AND Check2_61 <> 0 then
EXIT;
 
IF NOT(ODD(pr))then Begin result := 2; EXIT end;
Begin
result := 2;
EXIT;
end;
IF NOT(ODD(pr))then Begin result := 2; EXIT end;
 
For k := 1 to cntSmallPrimes-1 do
Begin
132

edits