OFFSET
1,2
LINKS
EXAMPLE
(1!)-1 (0) is reached from (2!)-1 (1) with one step by subtracting A034968(1) from 1.
(2!)-1 (1) is reached from (3!)-1 (5) with two steps by first subtracting A034968(5) from 5 -> 2, and then subtracting A034968(2) from 2 -> 1.
(3!)-1 (5) is reached from (4!)-1 (23) with five steps by repeatedly subtracting the sum of digits in factorial expansion as: 23 - 6 = 17, 17 - 5 = 12, 12 - 2 = 10, 10 - 3 = 7, 7 - 2 = 5.
Thus a(1)=1, a(2)=2 and a(3)=5.
MATHEMATICA
Table[Length@ NestWhileList[# - Total@ IntegerDigits[#, MixedRadix[Reverse@ Range[2, 120]]] &, (n + 1)! - 1, # > n! - 1 &] - 1, {n, 0, 8}] (* Michael De Vlieger, Jun 27 2016, Version 10.2 *)
PROG
(Scheme)
(define (A219661 n) (if (zero? n) n (let loop ((i (-1+ (A000142 (1+ n)))) (steps 1)) (cond ((isA000142? (1+ (A219651 i))) steps) (else (loop (A219651 i) (1+ steps)))))))
(define (isA000142? n) (and (> n 0) (let loop ((n n) (i 2)) (cond ((= 1 n) #t) ((not (zero? (modulo n i))) #f) (else (loop (/ n i) (1+ i)))))))
;; Alternative definition:
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Dec 03 2012
EXTENSIONS
Terms a(16) - a(20) computed with Hiroaki Yamanouchi's Python-program by Antti Karttunen, Jun 27 2016
STATUS
approved