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.

A276009 Decrement each nonzero digit by one in factorial base representation of n: a(n) = n - A276008(n).

This page as a plain text file.
%I A276009 #22 Feb 14 2024 01:04:59
%S A276009 0,0,0,0,2,2,0,0,0,0,2,2,6,6,6,6,8,8,12,12,12,12,14,14,0,0,0,0,2,2,0,
%T A276009 0,0,0,2,2,6,6,6,6,8,8,12,12,12,12,14,14,24,24,24,24,26,26,24,24,24,
%U A276009 24,26,26,30,30,30,30,32,32,36,36,36,36,38,38,48,48,48,48,50,50,48,48,48,48,50,50,54,54,54,54,56,56,60,60,60,60,62,62,72,72,72,72
%N A276009 Decrement each nonzero digit by one in factorial base representation of n: a(n) = n - A276008(n).
%H A276009 Antti Karttunen, <a href="/A276009/b276009.txt">Table of n, a(n) for n = 0..40320</a>
%H A276009 <a href="/index/Fa#facbase">Index entries for sequences related to factorial base representation</a>.
%F A276009 a(n) = n - A276008(n).
%e A276009 For n=23 whose factorial base representation is "321", when we subtract one from each digit we get "210", the factorial base representation of 14, thus a(23) = 14.
%e A276009 For n=37 ("1201"), when we subtract one from each digit we get "0100", thus a(37) = 6 as A007623(6) = 100.
%t A276009 a[n_] := Module[{k = n, m = 2, r, s = {}}, While[{k, r} = QuotientRemainder[k, m]; k != 0|| r != 0, AppendTo[s, r]; m++]; s = Max[# - 1, 0]& /@ s; Total[s*Range[Length[s]]!]]; Array[a, 100, 0] (* _Amiram Eldar_, Feb 14 2024 *)
%o A276009 (Scheme)
%o A276009 (define (A276009 n) (- n (A276008 n)))
%o A276009 ;; Standalone version:
%o A276009 (define (A276009 n) (let loop ((n n) (s 0) (f 1) (i 2)) (if (zero? n) s (let ((d (modulo n i))) (if (zero? d) (loop (/ n i) s (* i f) (+ 1 i)) (loop (/ (- n d) i) (+ s (* f (- d 1))) (* i f) (+ 1 i)))))))
%o A276009 (Python)
%o A276009 from sympy import factorial as f
%o A276009 def a007623(n, p=2): return n if n<p else a007623(n//p, p+1)*10 + n%p
%o A276009 def a(n):
%o A276009     x=str(a007623(n))
%o A276009     y="".join(str(int(i) - 1) if int(i)>0 else '0' for i in x)[::-1]
%o A276009     return sum([int(y[i])*f(i + 1) for i in range(len(y))])
%o A276009 print([a(n) for n in range(201)]) # _Indranil Ghosh_, Jun 21 2017
%Y A276009 Cf. A007623, A276008.
%Y A276009 Cf. also A257684, A257687, A266123, A266193.
%K A276009 nonn,base
%O A276009 0,5
%A A276009 _Antti Karttunen_, Aug 18 2016