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.

Showing 1-5 of 5 results.

A099563 a(0) = 0; for n > 0, a(n) = final nonzero number in the sequence n, f(n,2), f(f(n,2),3), f(f(f(n,2),3),4),..., where f(n,d) = floor(n/d); the most significant digit in the factorial base representation of n.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
Offset: 0

Views

Author

John W. Layman, Oct 22 2004

Keywords

Comments

Records in {a(n)} occur at {1,4,18,96,600,4320,35280,322560,3265920,...}, which appears to be n*n! = A001563(n).
The most significant digit in the factorial expansion of n (A007623). Proof: The algorithm that computes the factorial expansion of n, generates the successive digits by repeatedly dividing the previous quotient with successively larger divisors (the remainders give the digits), starting from n itself and divisor 2. As a corollary we find that A001563 indeed gives the positions of the records. - Antti Karttunen, Jan 01 2007.

Examples

			For n=15, f(15,2) = floor(15/2)=7, f(7,3)=2, f(2,4)=0, so a(15)=2.
From _Antti Karttunen_, Dec 24 2015: (Start)
Example illustrating the role of this sequence in factorial base representation:
   n  A007623(n)       a(n) [= the most significant digit].
   0 =   0               0
   1 =   1               1
   2 =  10               1
   3 =  11               1
   4 =  20               2
   5 =  21               2
   6 = 100               1
   7 = 101               1
   8 = 110               1
   9 = 111               1
  10 = 120               1
  11 = 121               1
  12 = 200               2
  13 = 201               2
  14 = 210               2
  15 = 211               2
  16 = 220               2
  17 = 221               2
  18 = 300               3
  etc.
Note that there is no any upper bound for the size of digits in this representation.
(End)
		

Crossrefs

Programs

  • Mathematica
    Table[Floor[n/#] &@ (k = 1; While[(k + 1)! <= n, k++]; k!), {n, 0, 120}] (* Michael De Vlieger, Aug 30 2016 *)
  • PARI
    A099563(n) = { my(i=2,dig=0); until(0==n, dig = n % i; n = (n - dig)/i; i++); return(dig); }; \\ Antti Karttunen, Dec 24 2015
    
  • Python
    def a(n):
        i=2
        d=0
        while n:
            d=n%i
            n=(n - d)//i
            i+=1
        return d
    print([a(n) for n in range(201)]) # Indranil Ghosh, Jun 21 2017, after PARI code
  • Scheme
    (define (A099563 n) (let loop ((n n) (i 2)) (let* ((dig (modulo n i)) (next-n (/ (- n dig) i))) (if (zero? next-n) dig (loop next-n (+ 1 i))))))
    (definec (A099563 n) (cond ((zero? n) n) ((= 1 (A265333 n)) 1) (else (+ 1 (A099563 (A257684 n)))))) ;; Based on given recurrence, using the memoization-macro definec
    ;; Antti Karttunen, Dec 24-25 2015
    

Formula

From Antti Karttunen, Dec 25 2015: (Start)
a(0) = 0; for n >= 1, if A265333(n) = 1 [when n is one of the terms of A265334], a(n) = 1, otherwise 1 + a(A257684(n)).
Other identities. For all n >= 0:
a(A001563(n)) = n. [Sequence works as a left inverse for A001563.]
a(n) = A257686(n) / A048764(n).
(End)

Extensions

a(0) = 0 prepended and the alternative description added to the name-field by Antti Karttunen, Dec 24 2015

A248034 a(n+1) gives the number of occurrences of the last digit of a(n) so far, up to and including a(n), with a(0)=0.

Original entry on oeis.org

0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 6, 6, 7, 6, 8, 6, 9, 6, 10, 7, 7, 8, 7, 9, 7, 10, 8, 8, 9, 8, 10, 9, 9, 10
Offset: 0

Views

Author

Eric Angelini and M. F. Hasler, Oct 11 2014

Keywords

Comments

In other words, the number to the right of a comma gives the number of occurrences of the digit immediately to the left of the comma, counting from the beginning up to that digit or comma.

Crossrefs

Cf. A249068 (analogous sequence in base 8).
Cf. A249009 (analogous sequence which uses the first, not the last digit).

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          coeff(b(n-1), x, irem(a(n-1), 10)))
        end:
    b:= proc(n) option remember; `if`(n=0, 1, b(n-1)+
          add(x^i, i=convert(a(n), base, 10)))
        end:
    seq(a(n), n=0..120);  # Alois P. Heinz, Oct 18 2014
  • Mathematica
    nn = 120; a[0] = j = 0; c[] := 0; Do[Map[c[#]++ &, IntegerDigits[j]]; a[n] = j = c[Mod[j, 10]], {n, nn}]; Array[a, nn, 0] (* _Michael De Vlieger, Aug 07 2023 *)
  • PARI
    c=vector(10);print1(a=0);for(n=1,99,apply(d->c[d+1]++,if(a,digits(a)));print1(","a=c[1+a%10]))
    (MIT/GNU Scheme)
    ;; An implementation of memoization-macro definec can be found for example from: http://oeis.org/wiki/Memoization
    (definec (A248034 n) (if (zero? n) n (vector-ref (A248034aux_digit_counts (- n 1)) (modulo (A248034 (- n 1)) 10))))
    (definec (A248034aux_digit_counts n) (cond ((zero? n) (vector 1 0 0 0 0 0 0 0 0 0)) (else (let loop ((digcounts-for-n (vector-copy (A248034aux_digit_counts (- n 1)))) (n (A248034 n))) (cond ((zero? n) digcounts-for-n) (else (vector-set! digcounts-for-n (modulo n 10) (+ 1 (vector-ref digcounts-for-n (modulo n 10)))) (loop digcounts-for-n (floor->exact (/ n 10)))))))))
    ;; Antti Karttunen, Oct 22 2014
    
  • Python
    from itertools import islice
    def A248034_gen(): # generator of terms
        c, clist = 0, [1]+[0]*9
        while True:
            yield c
            c = clist[c%10]
            for d in str(c):
                clist[int(d)] += 1
    A248034_list = list(islice(A248034_gen(),30)) # Chai Wah Wu, Dec 13 2022

A249009 a(n+1) gives the number of occurrences of the first digit of a(n) so far, up to and including a(n), with a(0)=0.

Original entry on oeis.org

0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 21, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 23, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 24, 6, 6, 7, 6, 8, 6, 9, 6, 10
Offset: 0

Views

Author

Alois P. Heinz, Oct 18 2014

Keywords

Comments

Inspired by A248034.

Crossrefs

Cf. A249069 (analogous sequence in factorial base).

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          coeff(b(n-1), x, convert(a(n-1), base, 10)[-1] ))
        end:
    b:= proc(n) option remember; `if`(n=0, 1, b(n-1)+
          add(x^i, i=convert(a(n), base, 10)))
        end:
    seq(a(n), n=0..120);
  • Python
    from itertools import islice
    def A249009_gen(): # generator of terms
        c, clist = 0, [1]+[0]*9
        while True:
            yield c
            c = clist[int(str(c)[0])]
            for d in str(c):
                clist[int(d)] += 1
    A249009_list = list(islice(A249009_gen(),100)) # Chai Wah Wu, Dec 13 2022

A249148 a(1) = 1, after which, if a(n-1) = 1, a(n) = 1 + the total number of 1's that have occurred in the sequence so far, otherwise a(n) = the total number of times the least prime dividing a(n-1) [i.e., A020639(a(n-1))] occurs as a divisor (counted with multiplicity for each term) in the previous terms from a(1) up to and including a(n-1).

Original entry on oeis.org

1, 2, 1, 3, 1, 4, 3, 2, 4, 6, 7, 1, 5, 1, 6, 8, 11, 1, 7, 2, 12, 14, 15, 6, 16, 20, 22, 23, 1, 8, 26, 27, 10, 28, 30, 31, 1, 9, 13, 2, 32, 37, 1, 10, 38, 39, 14, 40, 43, 1, 11, 3, 15, 16, 47, 1, 12, 49, 7, 8, 52, 54, 55, 9, 22, 56, 59, 1, 13, 5, 10, 60, 62, 63, 25, 14, 64, 70, 71, 1, 14, 72, 75, 28, 77, 15, 29, 1, 15, 30, 78, 79, 1, 16, 83
Offset: 1

Views

Author

Antti Karttunen, Oct 24 2014

Keywords

Comments

Inspired by A248034.
After a(1), it is very likely that 1's occur only just after primes, although they do not necessarily occur after every prime. For example, 13 is the first prime whose initial occurrence is not followed by 1.

Examples

			a(1) = 1 by definition.
For n = 2, we see that a(1) = 1, which is the only 1 that has occurred in the sequence so far, and thus a(2) = 1+1 = 2.
For n = 3, we see that a(2) = 2, with the least prime dividing it being 2, which has occurred so far only once (namely in a(2)), thus a(3) = 1.
For n = 4, we see that a(3) = 1, and there has occurred two 1's so far (as a(1) and a(3)), thus a(4) = 2+1 = 3.
For n = 5, we see that a(4) = 3, with the least prime dividing it being 3, which has occurred now just once, thus a(5) = 1.
For n = 6, we see that a(5) = 1, and there has occurred three 1's so far (as a(1), a(3) and a(5)), thus a(6) = 3+1 = 4.
For n = 7, we see that a(6) = 4 = 2*2, with its least prime 2 dividing it two times, and also occurring once at a(2), thus a(7) = 3.
		

Crossrefs

Programs

  • PARI
    A049084(n) = if(isprime(n), primepi(n), 0); \\ This function from Charles R Greathouse IV
    A249148_write_bfile(up_to_n) = { my(pfcounts, n, a_n, f, k); pfcounts = vector(up_to_n); a_n = 1; for(n = 1, up_to_n, if((1 == a_n), pfcounts[1]++; a_n = pfcounts[1], f=factor(a_n); for(i=1,#f~,k = A049084(f[i,1])+1; pfcounts[k] += f[i,2]); a_n = pfcounts[A049084(f[1,1])+1]); write("b249148.txt", n, " ", a_n)); };
    A249148_write_bfile(10000);
    (MIT/GNU Scheme) ;; With memoizing definec-macro from Antti Karttunen's IntSeq-library and factor function from Aubrey Jaffer's SLIB-library.
    (definec (A249148 n) (if (= 1 n) 1 (vector-ref (A249148aux_primefactor_counts (- n 1)) (A055396 (A249148 (- n 1))))))
    (definec (A249148aux_primefactor_counts n) (cond ((= 1 n) (vector 2)) (else (let* ((a_n (A249148 n)) (copy-of-prevec (vector-copy (A249148aux_primefactor_counts (- n 1)))) (newsize (max (vector-length copy-of-prevec) (+ 1 (A061395 a_n)))) (pf_counts_vec (vector-grow copy-of-prevec newsize))) (let loop ((pf_indices (map A049084 (factor a_n)))) (cond ((null? pf_indices) pf_counts_vec) (else (vector-set! pf_counts_vec (car pf_indices) (+ 1 (or (vector-ref pf_counts_vec (car pf_indices)) 0))) (loop (cdr pf_indices)))))))))

A249070 a(n+1) gives the number of occurrences of the maximum digit of a(n) in factorial base (i.e., A246359(a(n))) so far amongst the factorial base representations of all the terms up to and including a(n), with a(0)=0.

Original entry on oeis.org

0, 1, 1, 2, 3, 5, 1, 7, 9, 12, 2, 13, 3, 16, 5, 6, 18, 1, 19, 2, 21, 3, 25, 27, 30, 32, 35, 7, 40, 9, 44, 4, 10, 11, 12, 13, 14, 15, 16, 18, 5, 19, 6, 56, 20, 7, 61, 22, 8, 64, 26, 66, 9, 69, 10, 29, 30, 76, 11, 32, 81, 12, 33, 88, 13, 36, 37, 38, 39, 40, 42, 14, 43, 15, 44, 16, 46, 17, 49, 50, 51, 52
Offset: 0

Views

Author

Antti Karttunen, Oct 20 2014

Keywords

Examples

			   a(0) =  0 (by definition)
   a(1) =  1 ('1' in factorial base), as 0 has occurred once in all the preceding terms.
   a(2) =  1 as 1 has occurred once in all the preceding terms.
   a(3) =  2 ('10' in factorial base), as digit '1' has occurred two times in total in all the preceding terms.
   a(4) =  3 ('11' in factorial base), as '1' occurs once in each a(1) and a(2) and a(3).
   a(5) =  5 ('21' in factorial base), as '1' occurs once in each of a(1), a(2) and a(3) and twice at a(4).
   a(6) =  1 ('1' in factorial base), as '2' so far occurs only once at a(5)
   a(7) =  7 = '101'
   a(8) =  9 = '111'
   a(9) = 12 = '200'
  a(10) =  2 = '2'
  a(11) = 13 = '201'
  a(12) =  3 = '11'
  a(12) =  3 = '11'
  a(13) = 16 = '220'
  a(14) =  5 = '21'
  a(15) =  6 = '100'
  a(16) = 18 = '300'
  a(17) =  1 = '1'
  a(18) = 19 = '301'
  a(19) =  2 = '10'
  a(20) = 21 = '311'
  a(21) =  3 = '11'
  a(22) = 25 = '1001'
  a(23) = 27 = '1011'
  a(24) = 30 = '1100'
  a(25) = 32 = '1110'
  a(26) = 35 = '1121'
  a(27) =  7 (= '101' in factorial base), as the maximum digit in the factorial base representation of a(26), namely '2', has occurred in total 7 times in terms a(0) - a(26): once in each of a(5), a(9), a(11), a(14) and a(26), and twice in a(13).
		

Crossrefs

Differs from A249069 for the first time at n=27, where a(27) = 7, while A249069(27) = 38.
Showing 1-5 of 5 results.