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

A347381 Distance from n to the nearest common ancestor of n and sigma(n) in the Doudna-tree (A005940).

Original entry on oeis.org

0, 0, 1, 1, 1, 0, 3, 2, 2, 3, 3, 2, 2, 3, 1, 3, 6, 3, 5, 1, 4, 5, 7, 2, 3, 4, 3, 0, 8, 4, 10, 4, 4, 7, 2, 4, 4, 7, 3, 4, 10, 4, 9, 4, 3, 9, 13, 4, 4, 4, 7, 7, 15, 4, 5, 5, 6, 9, 15, 4, 7, 10, 3, 5, 4, 6, 12, 6, 8, 5, 19, 5, 9, 6, 4, 8, 3, 5, 19, 4, 3, 11, 20, 4, 7, 11, 9, 6, 22, 4, 4, 8, 11, 15, 7, 5, 24, 5, 3, 5, 20
Offset: 1

Views

Author

Antti Karttunen, Aug 30 2021

Keywords

Comments

a(n) tells about the degree of relatedness between n and sigma(n) in Doudna tree (see the illustration in A005940). It is 0 for those n where sigma(n) is one of the descendants of n, 1 for those n where the nearest common ancestor of n and sigma(n) is the parent of n, 2 for those n where the nearest common ancestor of n and sigma(n) is the grandparent of n, and so on.

Crossrefs

Indices of 0 .. 5 in this sequence are given by {2} U A336702, A347391, A347392, A347393, A347394, A374465.
Cf. A000203, A027687, A156552, A252463, A252464, A332221, A347380, A347383, A347384, A347390, A374481 [a(prime(n))], A374482 (indices of records), A374483 (record values).
Cf. also A336834.

Programs

  • PARI
    A000523(n) = logint(n,2);
    Abincompreflen(x, y) = if(!x || !y, 0, my(xl=A000523(x), yl=A000523(y), s=min(xl,yl), k=0); x >>= (xl-s); y >>= (yl-s); while(s>=0 && !bitand(1,bitxor(x>>s,y>>s)), s--; k++); (k));
    A156552(n) = {my(f = factor(n), p, p2 = 1, res = 0); for(i = 1, #f~, p = 1 << (primepi(f[i, 1]) - 1); res += (p * p2 * (2^(f[i, 2]) - 1)); p2 <<= f[i, 2]); res}; \\ From A156552
    A061395(n) = if(n>1, primepi(vecmax(factor(n)[, 1])), 0);
    A252464(n) = if(1==n,0,(bigomega(n) + A061395(n) - 1));
    A347381(n) = (A252464(n)-Abincompreflen(A156552(n), A156552(sigma(n))));
    
  • 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));
    A347381(n) = if(1==n,0, my(lista=List([]), i, k=n, stemvec, stemlen, sbr=sigma(n)); while(k>1, listput(lista,k); k = A252463(k)); stemvec = Vecrev(Vec(lista)); stemlen = #stemvec; while(1, if((i=vecsearch(stemvec,sbr))>0, return(stemlen-i)); sbr = A252463(sbr)));

Formula

a(n) = A252464(n) - A347380(n), where A347380(n) is the length of the common prefix in binary expansions of A156552(n) and A332221(n) = A156552(sigma(n)).

Extensions

Name changed, old name is now in formula section. - Antti Karttunen, Jul 09 2024

A348041 Square array read by antidiagonals. A(n,k) is the nearest common ancestor of n and k in the Doudna tree (A005940).

Original entry on oeis.org

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

Views

Author

Antti Karttunen and Peter Munn, Sep 27 2021

Keywords

Comments

Array is symmetric and is read by antidiagonals as A(1,1), A(1,2), A(2,1), A(1,3), A(2,2), A(3,1), ... .
Also the nearest common ancestor of n and k in the tree depicted in A163511 (the mirror image of the Doudna tree).
The first fork in the Doudna tree separates numbers divisible by the square of their largest prime factor (on one main branch) from other numbers greater than 2 (on the other main branch). If n and m are on different main branches then A(n, m) = 2.
In more general terms A(.,.) can be considered as a binary operation that evaluates certain differences between the prime factors of its operands. To start, compare the largest prime factor of each operand with the 2nd largest prime factor. As described above, 2 is the result if these 2 factors are the same in one operand, but are different in the other operand; otherwise 3 is the result if these 2 factors are consecutive primes in one operand, but are nonconsecutive primes in the other operand. Further cases are covered in the examples, but note it is the difference between the indices of the prime numbers that is significant.

Examples

			The top left 17x17 corner of the array:
  n/k |  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17
------+-------------------------------------------------------------
    1 |  1, 1, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1,  1,  1,  1,  1,  1,
    2 |  1, 2, 2, 2, 2, 2, 2, 2, 2,  2,  2,  2,  2,  2,  2,  2,  2,
    3 |  1, 2, 3, 2, 3, 3, 3, 2, 2,  3,  3,  3,  3,  3,  3,  2,  3,
    4 |  1, 2, 2, 4, 2, 2, 2, 4, 4,  2,  2,  2,  2,  2,  2,  4,  2,
    5 |  1, 2, 3, 2, 5, 3, 5, 2, 2,  5,  5,  3,  5,  5,  3,  2,  5,
    6 |  1, 2, 3, 2, 3, 6, 3, 2, 2,  3,  3,  6,  3,  3,  6,  2,  3,
    7 |  1, 2, 3, 2, 5, 3, 7, 2, 2,  5,  7,  3,  7,  7,  3,  2,  7,
    8 |  1, 2, 2, 4, 2, 2, 2, 8, 4,  2,  2,  2,  2,  2,  2,  8,  2,
    9 |  1, 2, 2, 4, 2, 2, 2, 4, 9,  2,  2,  2,  2,  2,  2,  4,  2,
   10 |  1, 2, 3, 2, 5, 3, 5, 2, 2, 10,  5,  3,  5,  5,  3,  2,  5,
   11 |  1, 2, 3, 2, 5, 3, 7, 2, 2,  5, 11,  3, 11,  7,  3,  2, 11,
   12 |  1, 2, 3, 2, 3, 6, 3, 2, 2,  3,  3, 12,  3,  3,  6,  2,  3,
   13 |  1, 2, 3, 2, 5, 3, 7, 2, 2,  5, 11,  3, 13,  7,  3,  2, 13,
   14 |  1, 2, 3, 2, 5, 3, 7, 2, 2,  5,  7,  3,  7, 14,  3,  2,  7,
   15 |  1, 2, 3, 2, 3, 6, 3, 2, 2,  3,  3,  6,  3,  3, 15,  2,  3,
   16 |  1, 2, 2, 4, 2, 2, 2, 8, 4,  2,  2,  2,  2,  2,  2, 16,  2,
   17 |  1, 2, 3, 2, 5, 3, 7, 2, 2,  5, 11,  3, 13,  7,  3,  2, 17,
.
The nearest common ancestor of 7 and 15 in the Doudna tree (see diagram in the links and A005940) is 3, thus A(7,15) = A(15,7) = 3.
The nearest common ancestor of 12 and 15 in the Doudna tree is 6, thus A(12,15) = A(15,12) = 6.
The nearest common ancestor of 4 and 27 is 4 because 27 is a descendant of 4 in the Doudna tree, thus A(4,27) = A(27,4) = 4.
Example without reference to the Doudna tree: (Start)
The method below works in general for A(.,.) considered as a binary operation, but we use A(20, 42) as our example.
(1) Write each operand as a product of primes in nondecreasing order, convert to a tuple of prime indices, decrement each index, take first differences, then reverse the order:
  20 = 2*2*5 = prime(1) * prime(1) * prime(3) -> (1,1,3) -> (0,0,2) -> (0,0,2) -> (2,0,0);
  42 = 2*3*7 = prime(1) * prime(2) * prime(4) -> (1,2,4) -> (0,1,3) -> (0,1,2) -> (2,1,0).
(2) Truncate each tuple after the first elements that differ between them (or at the length of the shorter tuple):
  (2,0,0) -> (2,0); (2,1,0) -> (2,1).
(3) Choose the lesser tuple: (2,0).
(4) Determine which number would generate this tuple by the process from step (1):
  10 = 2*5 = prime(1) * prime(3) -> (1,3) -> (0,2) -> (0,2) -> (2,0).
This gives A(20, 42) = 10.
(End)
		

Crossrefs

Cf. A000027 (main diagonal).
Cf. also A341510, A347380, A347381.

Programs

  • PARI
    up_to = 105;
    Abincompreflen(n, m) = { my(x=binary(n),y=binary(m),u=min(#x,#y)); for(i=1,u,if(x[i]!=y[i],return(i-1))); (u);};
    Abinprefix(n,k) = { my(digs=binary(n)); fromdigits(vector(k,i,digs[i]),2); };
    A005940(n) = { my(p=2, t=1); n--; until(!n\=2, if((n%2), (t*=p), p=nextprime(p+1))); (t); };
    A156552(n) = {my(f = factor(n), p, p2 = 1, res = 0); for(i = 1, #f~, p = 1 << (primepi(f[i, 1]) - 1); res += (p * p2 * (2^(f[i, 2]) - 1)); p2 <<= f[i, 2]); res}; \\ From A156552
    A348040sq(x,y) = Abincompreflen(A156552(x), A156552(y));
    A348041sq(x,y) = A005940(1+Abinprefix(A156552(x),A348040sq(x,y)));
    A348041list(up_to) = { my(v = vector(up_to), i=0); for(a=1,oo, for(col=1,a, i++; if(i > up_to, return(v)); v[i] = A348041sq(col,(a-(col-1))))); (v); };
    v348041 = A348041list(up_to);
    A348041(n) = v348041[n];
    
  • PARI
    \\ A348041sq can be defined also as:
    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));
    A348041sq(x,y) = if(1==x||1==y,1, my(lista=List([]), i, k=x, stemvec, h=y); while(k>1, listput(lista,k); k = A252463(k)); stemvec = Vecrev(Vec(lista)); while(1, if((i=vecsearch(stemvec,h))>0, return(stemvec[i])); h = A252463(h)));

Formula

A(n, 1) = A(1, n) = 1; otherwise if A241917(n) <> A241917(m) then A(n, m) = A000040(1 + min(A241917(2*n), A241917(2*m))); otherwise A(n, m) = x * A000040(A061395(x)+A241917(n)), where x = A(A052126(n), A052126(m)).
A(i, j) = A(j, i).
A(n, n) = n.
A(2, n) = 2 for all n > 1.
A(p, q) = min(p, q) for any primes p and q.
A(A070003(n), A102750(m)) = 2.
A(u^2, v^2) = A(u, v)^2.
A(4k+2, 6k+3) = A064989(2k+1) for all k >= 1.

A348040 Square array A(n,k) = the length of the common prefix in binary expansions of A156552(n) and A156552(k), read by antidiagonals.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 27 2021

Keywords

Examples

			The top left 17x17 corner of the array:
  n/k | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17
------+----------------------------------------------------
   1  | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   2  | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
   3  | 0, 1, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2,
   4  | 0, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1,
   5  | 0, 1, 2, 1, 3, 2, 3, 1, 1, 3, 3, 2, 3, 3, 2, 1, 3,
   6  | 0, 1, 2, 1, 2, 3, 2, 1, 1, 2, 2, 3, 2, 2, 3, 1, 2,
   7  | 0, 1, 2, 1, 3, 2, 4, 1, 1, 3, 4, 2, 4, 4, 2, 1, 4,
   8  | 0, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 3, 1,
   9  | 0, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 2, 1,
  10  | 0, 1, 2, 1, 3, 2, 3, 1, 1, 4, 3, 2, 3, 3, 2, 1, 3,
  11  | 0, 1, 2, 1, 3, 2, 4, 1, 1, 3, 5, 2, 5, 4, 2, 1, 5,
  12  | 0, 1, 2, 1, 2, 3, 2, 1, 1, 2, 2, 4, 2, 2, 3, 1, 2,
  13  | 0, 1, 2, 1, 3, 2, 4, 1, 1, 3, 5, 2, 6, 4, 2, 1, 6,
  14  | 0, 1, 2, 1, 3, 2, 4, 1, 1, 3, 4, 2, 4, 5, 2, 1, 4,
  15  | 0, 1, 2, 1, 2, 3, 2, 1, 1, 2, 2, 3, 2, 2, 4, 1, 2,
  16  | 0, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 4, 1,
  17  | 0, 1, 2, 1, 3, 2, 4, 1, 1, 3, 5, 2, 6, 4, 2, 1, 7,
		

Crossrefs

Cf. A252464 (main diagonal).
Cf. also A347380, A347381.

Programs

  • PARI
    up_to = 105;
    Abincompreflen(n, m) = { my(x=binary(n),y=binary(m),u=min(#x,#y)); for(i=1,u,if(x[i]!=y[i],return(i-1))); (u);};
    A156552(n) = {my(f = factor(n), p, p2 = 1, res = 0); for(i = 1, #f~, p = 1 << (primepi(f[i, 1]) - 1); res += (p * p2 * (2^(f[i, 2]) - 1)); p2 <<= f[i, 2]); res}; \\ From A156552
    A348040sq(x,y) = Abincompreflen(A156552(x), A156552(y));
    A348040list(up_to) = { my(v = vector(up_to), i=0); for(a=1,oo, for(col=1,a, i++; if(i > up_to, return(v)); v[i] = A348040sq(col,(a-(col-1))))); (v); };
    v348040 = A348040list(up_to);
    A348040(n) = v348040[n];

A364569 Length of the common prefix in the binary expansions of A156552(n) and n-1 [= A156552(A005940(n))].

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Aug 14 2023

Keywords

Crossrefs

Cf. also A347380.

Programs

  • PARI
    Abincompreflen(n, m) = { my(x=binary(n), y=binary(m), u=min(#x, #y)); for(i=1, u, if(x[i]!=y[i], return(i-1))); (u); };
    A364569(n) = Abincompreflen(A156552(n), (n-1));

A387422 The length of the maximal common prefix of the binary expansions of n and sigma(n), where sigma is the sum of divisors function.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 01 2025

Keywords

Crossrefs

Programs

  • Mathematica
    A387422[n_] := LengthWhile[Transpose[IntegerDigits[{n, DivisorSigma[1, n]}, 2][[All, ;; BitLength[n]]]], Equal @@ # &];
    Array[A387422, 100] (* Paolo Xausa, Sep 03 2025 *)
  • PARI
    A387422(n) = { my(a=binary(n), b=binary(sigma(n)), i=1); while(i<=#a,if(a[i]!=b[i],return(i-1)); i++); (#a); };
    
  • Python
    from os.path import commonprefix
    from sympy import divisor_sigma
    def A387422(n): return len(commonprefix([bin(n)[2:],bin(divisor_sigma(n))[2:]])) # Chai Wah Wu, Sep 03 2025

Formula

a(n) = (1+A000523(n)) - A387423(n).

A356320 Length of the common prefix in binary expansions of n and A332221(n) = A156552(sigma(A005940(1+n))).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Aug 06 2022

Keywords

Crossrefs

Programs

  • PARI
    A005940(n) = { my(p=2, t=1); n--; until(!n\=2, if((n%2), (t*=p), p=nextprime(p+1))); (t); };
    Abincompreflen(n, m) = { my(x=binary(n),y=binary(m),u=min(#x,#y)); for(i=1,u,if(x[i]!=y[i],return(i-1))); (u);};
    A156552(n) = {my(f = factor(n), p, p2 = 1, res = 0); for(i = 1, #f~, p = 1 << (primepi(f[i, 1]) - 1); res += (p * p2 * (2^(f[i, 2]) - 1)); p2 <<= f[i, 2]); res}; \\ From A156552
    A347380(n) = Abincompreflen(A156552(n), A156552(sigma(n)));
    A356320(n) = A347380(A005940(1+n));
    \\ Alternatively as:
    A356320(n) = Abincompreflen(n, A156552(sigma(A005940(1+n))));

A347382 a(n) = A252464(n) - A252464(A000593(n)).

Original entry on oeis.org

0, 1, 0, 2, 0, 1, 1, 3, -3, 1, 1, 2, 1, 2, -1, 4, 3, -2, 3, 2, 0, 2, 4, 3, -7, 2, -2, 3, 5, 0, 6, 5, 0, 4, -1, -1, 3, 4, 0, 3, 7, 1, 7, 3, -3, 5, 9, 4, -4, -6, 2, 3, 11, -1, 0, 4, 2, 6, 11, 1, 6, 7, -3, 6, 0, 1, 10, 5, 3, 0, 14, 0, 8, 4, -8, 5, -1, 1, 15, 4, -1, 8, 16, 2, 2, 8, 4, 4, 18, -2, -1, 6, 5, 10, 2, 5, 19
Offset: 1

Views

Author

Antti Karttunen, Aug 30 2021

Keywords

Crossrefs

Programs

  • Mathematica
    f[p_, e_] := If[p == 2, 1, NextPrime[p, -1]^e]; g[1] = 1; g[n_] := Times @@ f @@@ FactorInteger[n]; h[1] = 0; h[n_] := h[n] = If[EvenQ[n], h[n/2] + 1, h[g[n]] + 1]; a[n_] := h[n] - h[DivisorSigma[1, n/2^IntegerExponent[n, 2]]]; Array[a, 100] (* Amiram Eldar, Sep 19 2021 *)
  • PARI
    A000593(n) = sigma(n>>valuation(n, 2));
    A252464(n) = if(1==n,0,(bigomega(n) + A061395(n) - 1));
    A347382(n) = (A252464(n)-A252464(A000593(n)));

Formula

For all n >= 0, a(2^n) = n.
Showing 1-7 of 7 results.