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.

Original entry on oeis.org

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

Views

Author

Alonso del Arte, Jul 01 2017

Keywords

Comments

a(n) = 0 for n >= 34. - Georg Fischer, Mar 12 2019

Examples

			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
		

Crossrefs

Programs

  • 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
    
  • Mathematica
    Table[Mod[n!, 2^32] - Boole[Mod[n!, 2^32] > 2^31 - 1] * 2^32, {n, 0, 49}]
  • 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
    
  • 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
  • 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