|
|
A289282
|
|
The least significant four bytes of n! interpreted in two's complement.
|
|
1
|
|
|
1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 1932053504, 1278945280, 2004310016, 2004189184, -288522240, -898433024, 109641728, -2102132736, -1195114496, -522715136, 862453760, -775946240, 2076180480, -1853882368, 1484783616, -1375731712, -1241513984, 1409286144, 738197504, -2147483648, -2147483648, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
|
|
LINKS
|
|
|
EXAMPLE
|
The hexadecimal column in the following list shows how the bits in the least significant four bytes are shifted to the left by each factor containing some power of 2. With two's complement the terms are negative when the highest bit is one. - Georg Fischer, Mar 13 2019
28 -1375731712 # ae000000
29 -1241513984 # b6000000
30 1409286144 # 54000000
31 738197504 # 2c000000
32 -2147483648 # 80000000
33 -2147483648 # 80000000
34 0 # 00000000
|
|
MATHEMATICA
|
Table[Mod[n!, 2^32] - Boole[Mod[n!, 2^32] > 2^31 - 1] * 2^32, {n, 0, 49}]
|
|
PROG
|
(Java) import java.math.BigInteger;
public class a289282 {
public static void main(String[] args) {
BigInteger pow32 = BigInteger.valueOf(2).pow(32);
BigInteger bfact = BigInteger.ONE;
for (int i = 0; i < 48; i++) {
bfact = bfact.multiply(BigInteger.valueOf(i == 0 ? 1 : i));
System.out.println(String.valueOf(i) + " "
+ String.valueOf(bfact.mod(pow32).intValue()));
}
} // main
(PARI) Bits = 32; N = Mod(1, 2^Bits); j = 0; until(N == 0, print1(-centerlift(-N), ", "); j += 1; N *= j); \\ Jack Brennen, Jun 30 2017
(Scala) (1 to 36).scanLeft(1)(_ * _) // Scala infers 1 and 36 are Int, which become int primitives in the Java Virtual Machine. - Alonso del Arte, Mar 02 2019
(Python)
import math
f = math.factorial(n)
least_four = f & 0xffffffff
mask = 0x7fffffff
return (least_four & mask) - (least_four & ~mask)
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|