Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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
OFFSET
0,3
COMMENTS
a(n) = 0 for n >= 34. - Georg Fischer, Mar 12 2019
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
} // Georg Fischer, Mar 12 2019
(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
def A289282(n):
f = math.factorial(n)
least_four = f & 0xffffffff
mask = 0x7fffffff
return (least_four & mask) - (least_four & ~mask)
print([A289282(n) for n in range(37)]) # Peter Luschny, Mar 13 2019
CROSSREFS
Sequence in context: A230233 A154659 A254523 * A155456 A124355 A133942
KEYWORD
sign,easy
AUTHOR
Alonso del Arte, Jul 01 2017
STATUS
approved