login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A289282 The least significant four bytes of n! interpreted in two's complement. 1

%I #38 Aug 09 2021 21:12:00

%S 1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,

%T 1932053504,1278945280,2004310016,2004189184,-288522240,-898433024,

%U 109641728,-2102132736,-1195114496,-522715136,862453760,-775946240,2076180480,-1853882368,1484783616,-1375731712,-1241513984,1409286144,738197504,-2147483648,-2147483648,0,0,0

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

%C a(n) = 0 for n >= 34. - _Georg Fischer_, Mar 12 2019

%e 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 28 -1375731712 # ae000000

%e 29 -1241513984 # b6000000

%e 30 1409286144 # 54000000

%e 31 738197504 # 2c000000

%e 32 -2147483648 # 80000000

%e 33 -2147483648 # 80000000

%e 34 0 # 00000000

%t Table[Mod[n!, 2^32] - Boole[Mod[n!, 2^32] > 2^31 - 1] * 2^32, {n, 0, 49}]

%o (Java) import java.math.BigInteger;

%o public class a289282 {

%o public static void main(String[] args) {

%o BigInteger pow32 = BigInteger.valueOf(2).pow(32);

%o BigInteger bfact = BigInteger.ONE;

%o for (int i = 0; i < 48; i++) {

%o bfact = bfact.multiply(BigInteger.valueOf(i == 0 ? 1 : i));

%o System.out.println(String.valueOf(i) + " "

%o + String.valueOf(bfact.mod(pow32).intValue()));

%o }

%o } // main

%o } // _Georg Fischer_, Mar 12 2019

%o (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 (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 (Python)

%o import math

%o def A289282(n):

%o f = math.factorial(n)

%o least_four = f & 0xffffffff

%o mask = 0x7fffffff

%o return (least_four & mask) - (least_four & ~mask)

%o print([A289282(n) for n in range(37)]) # _Peter Luschny_, Mar 13 2019

%Y Cf. A000142, A036603.

%K sign,easy

%O 0,3

%A _Alonso del Arte_, Jul 01 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 17 21:11 EDT 2024. Contains 375227 sequences. (Running on oeis4.)