OFFSET
0,4
COMMENTS
Let n$ denote the swinging factorial. a(n) = n$ / 2^sigma(n) where sigma(n) is the exponent of 2 in the prime-factorization of n$. sigma(n) can be computed as the number of '1's in the base 2 representation of floor(n/2).
If n is even then a(n) is the numerator of the reduced ratio (n-1)!!/n!! = A001147(n-1)/A000165(n), and if n is odd then a(n) is the numerator of the reduced ratio n!!/(n-1)!! = A001147(n)/A000165(n-1). The denominators for each ratio should be compared to A060818. Here all ratios are reduced. - Anthony Hernandez, Feb 05 2020 [See the Mathematica program for a more compact form of the formula. Peter Luschny, Mar 01 2020 ]
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
Peter Luschny, Die schwingende Fakultät und Orbitalsysteme, August 2011.
Peter Luschny, Swinging Factorial.
FORMULA
a(2*n) = A001790(n).
a(2*n+1) = A001803(n).
a(n) = a(n-1)*n^((-1)^(n+1))*2^valuation(n, 2) for n > 0. - Peter Luschny, Sep 29 2019
EXAMPLE
11$ = 2772 = 2^2*3^2*7*11. Therefore a(11) = 3^2*7*11 = 2772/4 = 693.
From Anthony Hernandez, Feb 04 2019: (Start)
a(7) = numerator((1*3*5*7)/(2*4*6)) = 35;
a(8) = numerator((1*3*5*7)/(2*4*6*8)) = 35;
a(9) = numerator((1*3*5*7*9)/(2*4*6*8)) = 315;
a(10) = numerator((1*3*5*7*9)/(2*4*6*8*10)) = 63. (End)
MAPLE
swing := proc(n) option remember; if n = 0 then 1 elif irem(n, 2) = 1 then swing(n-1)*n else 4*swing(n-1)/n fi end:
sigma := n -> 2^(add(i, i= convert(iquo(n, 2), base, 2))):
a := n -> swing(n)/sigma(n);
MATHEMATICA
sf[n_] := With[{f = Floor[n/2]}, Pochhammer[f+1, n-f]/ f!]; a[n_] := With[{s = sf[n]}, s/2^IntegerExponent[s, 2]]; Table[a[n], {n, 0, 31}] (* Jean-François Alcover, Jul 26 2013 *)
r[n_] := (n - Mod[n - 1, 2])!! /(n - 1 + Mod[n - 1, 2])!! ;
Table[r[n], {n, 0, 36}] // Numerator (* Peter Luschny, Mar 01 2020 *)
PROG
(Sage) # uses[A000120]
@CachedFunction
def swing(n):
if n == 0: return 1
return swing(n-1)*n if is_odd(n) else 4*swing(n-1)/n
[A163590(n) for n in (0..31)] # Peter Luschny, Nov 19 2012
# Alternatively:
(Sage)
@cached_function
def A163590(n):
if n == 0: return 1
return A163590(n - 1) * n^((-1)^(n + 1)) * 2^valuation(n, 2)
print([A163590(n) for n in (0..31)]) # Peter Luschny, Sep 29 2019
(PARI)
A163590(n) = {
my(a = vector(n+1)); a[1] = 1;
for(n = 1, n,
a[n+1] = a[n]*n^((-1)^(n+1))*2^valuation(n, 2));
a } \\ Peter Luschny, Sep 29 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Aug 01 2009
STATUS
approved