%I #60 Sep 27 2024 23:16:43
%S 1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,-1,1,1,
%T -1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,1,-1,-1,1,1,-1,
%U -1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1
%N The unique function f with f(1)=1 and f(jD!+k)=(-1)^j f(k) for all D, j=1..D, and k=1..D!.
%C sup_n |Sum_{j=1..n} f(jd)| is finite (but not bounded) for all d, thus giving a counterexample to a strong form of the Erdős discrepancy conjecture (see Remark 1.14 on p. 7 of Tao paper).
%H Antti Karttunen, <a href="/A262725/b262725.txt">Table of n, a(n) for n = 1..40320</a>
%H Terence Tao, <a href="http://arxiv.org/abs/1509.05363">The Erdős discrepancy problem</a>, arXiv:1509.05363 [math.CO], 2016.
%H <a href="/index/Fa#facbase">Index entries for sequences related to factorial base representation</a>
%F a(n) = (-1)^A034968(n-1). - _Antti Karttunen_ and _Peter Munn_, Aug 09 2024
%t (* Generates terms recursively, using definition *)
%t Module[{dmax = 4, i = 2, a}, a = Table[1, (dmax+1)!]; For[d = 1, d <= dmax, d++, For[j = 1, j <= d, j++, For[k = 1, k <= d!, k++, a[[i++]] = (-1)^j*a[[k]]]]]; a] (* _Paolo Xausa_, Aug 10 2024 *)
%t (* Generates terms individually, via A034968 (slower) *)
%t A034968[n_] := Module[{a = n, i = 2}, While[i! <= n, a-=(i-1)*Floor[n/i++!]]; a];
%t Array[(-1)^A034968[#] &, 5!, 0] (* _Paolo Xausa_, Aug 10 2024 *)
%o (Sage)
%o A=[1,1]
%o for D in [1..4]:
%o j=1
%o while j<=D:
%o k=1
%o while k<=factorial(D):
%o A.append((-1)^j*A[k])
%o k+=1
%o j+=1
%o A[1:73] # _Tom Edgar_, Sep 29 2015
%o (PARI)
%o A034968(n) = { my(s=0, b=2, d); while(n, d = (n%b); s += d; n = (n-d)/b; b++); (s); };
%o A262725(n) = ((-1)^A034968(n-1)); \\ _Antti Karttunen_, Aug 09 2024
%o (Python)
%o from math import factorial
%o def aupto(n):
%o f = [1, 1]
%o for D in range(1, 5):
%o for j in range(1, D + 1):
%o sign = (-1) ** j
%o f.extend(sign * f[k] for k in range(1, factorial(D) + 1))
%o return f[1:n] # _Paul Muljadi_, Sep 26 2024
%Y Cf. A034968, A237695, A374468.
%Y Cf. also A343785 (another example from Tao paper).
%K easy,sign
%O 1
%A _Terence Tao_, Sep 28 2015