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.

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

Original entry on oeis.org

0, 0, 1, 0, 2, 2, 5, 0, 0, 4, 11, 4, 22, 10, 5, 0, 44, 0, 89, 8, 8, 22, 179, 8, 0, 44, 1, 20, 358, 10, 717, 0, 20, 88, 11, 0, 1434, 178, 45, 16, 2868, 16, 5737, 44, 8, 358, 11475, 16, 0, 0, 89, 88, 22950, 2, 17, 40, 176, 716, 45901, 20, 91802, 1434, 17, 0, 40, 40, 183605, 176, 356, 22, 367211, 0, 734422, 2868, 1, 356, 22, 90, 1468845, 32, 0, 5736, 2937691, 32
Offset: 1

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

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

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] == 3, 1, 0], 2], {n, 84}] (* 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));
    A292383(n) = if(1==n,0,(if(3==(n%4),1,0)+(2*A292383(A252463(n)))));
    
  • Scheme
    (define (A292383 n) (A292373 (A292384 n)))

Formula

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

A292371 A binary encoding of 1-digits in the base-4 representation of n.

Original entry on oeis.org

0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 4, 5, 4, 4, 6, 7, 6, 6, 4, 5, 4, 4, 4, 5, 4, 4, 0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 8, 9, 8, 8, 10, 11, 10, 10, 8, 9, 8, 8, 8, 9, 8, 8, 12, 13, 12, 12, 14, 15, 14, 14, 12, 13, 12, 12, 12, 13, 12, 12, 8, 9, 8, 8, 10, 11, 10, 10, 8, 9, 8, 8, 8, 9, 8, 8, 8
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        1          1           1
   2        0          2           0
   3        0          3           0
   4        2         10          10
   5        3         11          11
   6        2         12          10
   7        2         13          10
   8        0         20           0
   9        1         21           1
  10        0         22           0
  11        0         23           0
  12        0         30           0
  13        1         31           1
  14        0         32           0
  15        0         33           0
  16        4        100         100
  17        5        101         101
  18        4        102         100
		

Crossrefs

Cf. A289813 (analogous sequence for base 3).

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 1, 1, 0], 2], {n, 0, 112}] (* 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==1 else '0' for i in k), 2)
    print([a(n) for n in range(116)]) # Indranil Ghosh, Sep 21 2017
    
  • Python
    def A292371(n): return int(bin(n&~(n>>1))[:1:-2][::-1],2) # Chai Wah Wu, Jun 30 2022

Formula

a(n) = A059905(A292272(n)) = A059905(n AND A003188(n)), where AND is bitwise-AND (A004198).
For all n >= 0, A000120(a(n)) = A160381(n).

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).

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