- or download this
$n <<= 1 while $n & 0xfff;
- or download this
for( c = 1; ( ~n & 1 ) && ( c < 4096 ); c <<= 1 ) n >>= 1;
lcm = n * 4096;
- or download this
while( n & 0xfff ) n <<= 1;
lcm = n;
- or download this
C:\test\C>gcm
gcm : 2132901888
...
anonyM: gcm for s=2147483648 & r=1 to 1073741824 took:33.850023994460
anonyM: gcm2 for s=2147483648 & r=1 to 1073741824 took:46.293298113614
anonyM: gcm3 for s=2147483648 & r=1 to 1073741824 took:64.208097030422
- or download this
U64 gcm2( U64 max, U64 n ) {
U32 b;
...
lcm = n * 4096;
return ( max / lcm ) * lcm;
}
- or download this
PUBLIC gcm2
; Function compile flags: /Ogtpy
...
ret 0
gcm2 ENDP
- or download this
PUBLIC gcm
; Function compile flags: /Ogtpy
...
ret 0
gcm ENDP
- or download this
C:\test\C>gcm
anonyM: gcm for s=2147483648 & r=1 to 1073741824 took: 33.92063749171
+5
anonyM: gcm2 for s=2147483648 & r=1 to 1073741824 took: 46.15194765908
+9
oiskuu: gcm for s=2147483648 & r=1 to 1073741824 took:330.49201177311
+0