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-6 of 6 results.

A292381 Base-2 expansion of a(n) encodes the steps where numbers of the form 4k+1 are encountered when map x -> A252463(x) is iterated down to 1, starting from x=n.

Original entry on oeis.org

1, 2, 4, 4, 9, 8, 18, 8, 9, 18, 36, 16, 73, 36, 16, 16, 147, 18, 294, 36, 37, 72, 588, 32, 19, 146, 16, 72, 1177, 32, 2354, 32, 73, 294, 32, 36, 4709, 588, 144, 72, 9419, 74, 18838, 144, 33, 1176, 37676, 64, 39, 38, 292, 292, 75353, 32, 74, 144, 589, 2354, 150706, 64, 301413, 4708, 72, 64, 147, 146, 602826, 588, 1177, 64, 1205652, 72, 2411305, 9418, 36, 1176
Offset: 1

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			For n = 1, the starting value (which is also the ending point) is of the form 4k+1, thus a(1) = 1*(2^0) = 1.
For n = 2, the starting value is not of the form 4k+1, but its parent, A252463(2) = 1 is, thus a(2) = 0*(2^0) + 1*(2^1) = 2.
For n = 3, the starting value is not of the form 4k+1, after which follows 2 (also not 4k+1), and then 2 -> 1, and it is only the end-point of iteration which is of the form 4k+1, thus a(3) = 0*(2^0) + 0*(2^1) + 1*(2^2) = 4.
For n = 5, the starting value is of the form 4k+1, after which follows A252463(5) = 3 (which is not), and then continuing as before as 3 -> 2 -> 1, thus a(5) = 1*(2^0) + 0*(2^1) + 0*(2^2) + 1*(2^3) = 9.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[Reverse@ NestWhileList[Function[k, Which[k == 1, 1, EvenQ@ k, k/2, True, Times @@ Power[Which[# == 1, 1, # == 2, 1, True, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger@ k]], n, # > 1 &] /. k_ /; IntegerQ@ k :> If[Mod[k, 4] == 1, 1, 0], 2], {n, 76}] (* Michael De Vlieger, Sep 21 2017 *)
  • PARI
    A064989(n) = {my(f); f = factor(n); if((n>1 && f[1,1]==2), f[1,2] = 0); for (i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f)};
    A252463(n) = if(!(n%2),n/2,A064989(n));
    A292381(n) = if(1==n,n,(if(1==(n%4),1,0)+(2*A292381(A252463(n)))));
    
  • Python
    from sympy.core.cache import cacheit
    from sympy.ntheory.factor_ import digits
    from sympy import factorint, prevprime
    from operator import mul
    from functools import reduce
    def a292371(n):
        k=digits(n, 4)[1:]
        return 0 if n==0 else int("".join(['1' if i==1 else '0' for i in k]), 2)
    def a064989(n):
        f=factorint(n)
        return 1 if n==1 else reduce(mul, [1 if i==2 else prevprime(i)**f[i] for i in f])
    def a252463(n): return 1 if n==1 else n//2 if n%2==0 else a064989(n)
    @cacheit
    def a292384(n): return 1 if n==1 else 4*a292384(a252463(n)) + n%4
    def a(n): return a292371(a292384(n))
    print([a(n) for n in range(1, 111)]) # Indranil Ghosh, Sep 21 2017
  • Scheme
    (define (A292381 n) (A292371 (A292384 n)))
    

Formula

a(1) = 1; for n > 1, a(n) = 2*a(A252463(n)) + [n ≡ 1 (mod 4)], where the last part of the formula is Iverson bracket, giving 1 only if n is of the form 4k+1, and 0 otherwise.
a(n) = A292371(A292384(n)).
Other identities. For n >= 1:
a(2n) = 2*a(n).
A000120(a(n)) = A292375(n).
For n >= 2, a(n) = A004754(A292385(n)).

A292272 a(n) = n - A048735(n) = n - (n AND floor(n/2)).

Original entry on oeis.org

0, 1, 2, 2, 4, 5, 4, 4, 8, 9, 10, 10, 8, 9, 8, 8, 16, 17, 18, 18, 20, 21, 20, 20, 16, 17, 18, 18, 16, 17, 16, 16, 32, 33, 34, 34, 36, 37, 36, 36, 40, 41, 42, 42, 40, 41, 40, 40, 32, 33, 34, 34, 36, 37, 36, 36, 32, 33, 34, 34, 32, 33, 32, 32, 64, 65, 66, 66, 68, 69, 68, 68, 72, 73, 74, 74, 72, 73, 72, 72, 80, 81, 82, 82, 84, 85, 84, 84, 80, 81, 82, 82, 80, 81
Offset: 0

Views

Author

Antti Karttunen, Sep 16 2017

Keywords

Comments

In binary expansion of n, change those 1's to 0's that have an 1-bit next to them at their left (more significant) side. Only fibbinary numbers (A003714) occur as terms.

Examples

			From _Kevin Ryde_, Jun 02 2020: (Start)
     n = 1831 = binary 11100100111
  a(n) = 1060 = binary 10000100100   high 1 of each run
(End)
		

Crossrefs

Programs

Formula

a(n) = n - A048735(n) = n - (n AND floor(n/2)) = n XOR (n AND floor(n/2)), where AND is bitwise-AND (A004198) and XOR is bitwise-XOR (A003987).
a(n) = n AND A003188(n).
a(n) = A292382(A005940(1+n)).
A059905(a(n)) = A292371(n).
For all n >= 0, A085357(a(n)) = 1.
a(n) = A213064(n) / 2. - Kevin Ryde, Jun 02 2020
a(n) = n AND NOT floor(n/2). - Chai Wah Wu, Jun 29 2022

A292372 A binary encoding of 2-digits in base-4 representation of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 3, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 3, 2, 0, 0, 1, 0, 4, 4, 5, 4, 4, 4, 5, 4, 6, 6, 7, 6, 4, 4, 5, 4, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 3, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 3, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 3, 2, 0, 0, 1, 0, 4, 4, 5, 4, 4, 4, 5, 4, 6, 6, 7, 6, 4, 4, 5, 4, 0, 0, 1, 0, 0, 0, 1, 0, 2
Offset: 0

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			   n      a(n)     base-4(n)  binary(a(n))
                  A007090(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        0          1           0
   2        1          2           1
   3        0          3           0
   4        0         10           0
   5        0         11           0
   6        1         12           1
   7        0         13           0
   8        2         20          10
   9        2         21          10
  10        3         22          11
  11        2         23          10
  12        0         30           0
  13        0         31           0
  14        1         32           1
  15        0         33           0
  16        0        100           0
  17        0        101           0
  18        1        102           1
		

Crossrefs

Cf. A289814 (analogous sequence for base-3).

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 2, 1, 0], 2], {n, 0, 120}] (* Michael De Vlieger, Sep 21 2017 *)
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n):
        k=digits(n, 4)[1:]
        return 0 if n==0 else int("".join('1' if i==2 else '0' for i in k), 2)
    print([a(n) for n in range(121)]) # Indranil Ghosh, Sep 21 2017
    
  • Python
    def A292372(n): return 0 if (m:=n&~(n<<1)) < 2 else int(bin(m)[-2:1:-2][::-1],2) # Chai Wah Wu, Jun 30 2022

Formula

a(n) = A059906(n AND A048724(n)), where AND is a bitwise-AND (A004198).
For all n >= 0, A000120(a(n)) = A160382(n).

A292373 A binary encoding of 3-digits in base-4 representation of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 4, 4, 4, 5, 4, 4, 4, 5, 6, 6, 6, 7, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 4, 4, 4, 5, 4
Offset: 0

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			   n      a(n)     base-4(n)  binary(a(n))
                  A007090(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        0          1           0
   2        0          2           0
   3        1          3           1
   4        0         10           0
   5        0         11           0
   6        0         12           0
   7        1         13           1
   8        0         20           0
   9        0         21           0
  10        0         22           0
  11        1         23           1
  12        2         30          10
  13        2         31          10
  14        2         32          10
  15        3         33          11
  16        0        100           0
  17        0        101           0
  18        0        102           0
  19        1        103           1
		

Crossrefs

Programs

  • Python
    def A292373(n): return int(bin(n&n>>1)[:1:-2][::-1],2) # Chai Wah Wu, Jun 30 2022

Formula

a(n) = A059905(A048735(n)) = A059906(A213370(n)).
For all n >= 0, A000120(a(n)) = A160383(n).

A292370 A binary encoding of the zeros in base-4 representation of n.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 7, 6, 6, 6, 5, 4, 4, 4, 5, 4, 4, 4, 5, 4, 4, 4, 3, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 1
Offset: 0

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			   n      a(n)     base-4(n)  binary(a(n))
                  A007090(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        0          1           0
   2        0          2           0
   3        0          3           0
   4        1         10           1
   5        0         11           0
   6        0         12           0
   7        0         13           0
   8        1         20           1
   9        0         21           0
  10        0         22           0
  11        0         23           0
  12        1         30           1
  13        0         31           0
  14        0         32           0
  15        0         33           0
  16        3        100          11
  17        2        101          10
		

Crossrefs

Cf. A291770 (analogous sequence for base-3).

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 0, 1, 0], 2], {n, 0, 120}] (* Michael De Vlieger, Sep 21 2017 *)
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n):
        k=digits(n, 4)[1:]
        return 0 if n==0 else int("".join('1' if i==0 else '0' for i in k), 2)
    print([a(n) for n in range(111)]) # Indranil Ghosh, Sep 21 2017
  • Scheme
    (define (A292370 n) (if (zero? n) n (let loop ((n n) (b 1) (s 0)) (if (< n 4) s (let ((d (modulo n 4))) (if (zero? d) (loop (/ n 4) (+ b b) (+ s b)) (loop (/ (- n d) 4) (+ b b) s)))))))
    

Formula

For all n >= 0, A000120(a(n)) = A160380(n).

A309952 XOR contraction of binary representation of n.

Original entry on oeis.org

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

Views

Author

Florian Lang, Aug 24 2019

Keywords

Comments

To calculate a(n) write down the binary representation of n. Organize the digits in pairs and calculate the xor of these pairs. The result is a(n) in binary.
Conjecture: The index of the first occurrence of k in a is A000695(k). - Ivan N. Ianakiev, Aug 26 2019

Examples

			For n=19 we have the binary representation 10011 = 01 00 11. Calculating the xor of the pairs gives 1 0 0 which is 4 in binary and therefore a(19) = 4.
		

Crossrefs

Programs

  • Maple
    a:= n-> `if`(n=0, 0, (r-> 2*a((n-r)/4) +r*(3-r)/2)(irem(n, 4))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Aug 26 2019
  • PARI
    a(n) = {my(b = Vecrev(binary(n)), nb = #b\2, val = fromdigits(Vecrev(vector(nb, i, bitxor(b[2*i-1], b[2*i]))), 2)); if (#b % 2, val += 2^nb); val;} \\ Michel Marcus, Aug 26 2019
  • Python
    def a(n):
        n = [int(k) for k in bin(n)[2:]]
        if len(n) % 2 != 0:
            n = [0] + n
        result = []
        for i in range(0, len(n), 2):
            result.append(n[i] ^ n[i+1]) #xor
        return int("".join([str(k) for k in result]), 2)
    
  • Python
    from itertools import zip_longest
    from operator import xor
    def A309952(n): return int(''.join(map(lambda x:str(xor(*x)),zip_longest((s:=tuple(int(d) for d in bin(n)[2:]))[::-2],s[-2::-2],fillvalue=0)))[::-1],2) # Chai Wah Wu, Jun 30 2022
    

Formula

a(n) = A292371(n) + A292372(n). - Rémy Sigrist, Aug 25 2019
a(0) = 0, a(4n) = 2*a(n), a(4n+1) = 2*a(n)+1, a(4n+2) = 2*a(n)+1, a(4n+3) = 2*a(n). - Florian Lang, Aug 26 2019
Showing 1-6 of 6 results.