cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A289282 The least significant four bytes of n! interpreted in two's complement.

This page as a plain text file.
%I A289282 #38 Aug 09 2021 21:12:00
%S A289282 1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,
%T A289282 1932053504,1278945280,2004310016,2004189184,-288522240,-898433024,
%U A289282 109641728,-2102132736,-1195114496,-522715136,862453760,-775946240,2076180480,-1853882368,1484783616,-1375731712,-1241513984,1409286144,738197504,-2147483648,-2147483648,0,0,0
%N A289282 The least significant four bytes of n! interpreted in two's complement.
%C A289282 a(n) = 0 for n >= 34. - _Georg Fischer_, Mar 12 2019
%e A289282 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
%e A289282   28 -1375731712 # ae000000
%e A289282   29 -1241513984 # b6000000
%e A289282   30  1409286144 # 54000000
%e A289282   31   738197504 # 2c000000
%e A289282   32 -2147483648 # 80000000
%e A289282   33 -2147483648 # 80000000
%e A289282   34           0 # 00000000
%t A289282 Table[Mod[n!, 2^32] - Boole[Mod[n!, 2^32] > 2^31 - 1] * 2^32, {n, 0, 49}]
%o A289282 (Java) import java.math.BigInteger;
%o A289282 public class a289282 {
%o A289282     public static void main(String[] args) {
%o A289282         BigInteger pow32 = BigInteger.valueOf(2).pow(32);
%o A289282         BigInteger bfact  = BigInteger.ONE;
%o A289282         for (int i = 0; i < 48; i++) {
%o A289282             bfact = bfact.multiply(BigInteger.valueOf(i == 0 ? 1 : i));
%o A289282             System.out.println(String.valueOf(i) + " "
%o A289282                 + String.valueOf(bfact.mod(pow32).intValue()));
%o A289282         }
%o A289282     } // main
%o A289282 } // _Georg Fischer_, Mar 12 2019
%o A289282 (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
%o A289282 (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
%o A289282 (Python)
%o A289282 import math
%o A289282 def A289282(n):
%o A289282     f = math.factorial(n)
%o A289282     least_four = f & 0xffffffff
%o A289282     mask = 0x7fffffff
%o A289282     return (least_four & mask) - (least_four & ~mask)
%o A289282 print([A289282(n) for n in range(37)]) # _Peter Luschny_, Mar 13 2019
%Y A289282 Cf. A000142, A036603.
%K A289282 sign,easy
%O A289282 0,3
%A A289282 _Alonso del Arte_, Jul 01 2017