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-10 of 24 results. Next

A292583 Restricted growth sequence transform of A278222(A292383(n)); a filter related to runs of numbers of the form 4k+3 encountered on trajectories of A005940-tree.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 20 2017

Keywords

Comments

Term a(n) essentially records the run lengths of numbers of form 4k+3 encountered when starting from that node in binary tree A005940 which contains n, and by then traversing towards the root by iterating the map n -> A252463(n). The actual run lengths can be read from the exponents of primes in the prime factorization of A278222(A292383(m)), where m = min_{k=1..n} for which a(k) = a(n). In compound filter A292584 this is combined with similar information about the run lengths of the numbers of the form 4k+1 (A292585).
From Antti Karttunen, Sep 25 2017: (Start)
For all i, j: a(i) = a(j) => A053866(i) = A053866(j).
This follows from the interpretation of A053866 (A093709) as the characteristic function of squares and twice-squares. In binary tree A005940 each number is "born" by repeated applications of two functions: when we descend leftward we apply A003961, which shifts all prime factors of n one step towards larger primes. On the other hand, when we descend rightward the terms grow by doubling: n -> 2n (A005843). No square is ever of the form 4k+3, and for any square x, A003961(x) is also a square. Multiplying a square by 2 gives twice a square, and then multiplying by 2 again gives 4*square, which is also a square. In general, applying an even number of doubling steps in succession keeps a square as a square, while an odd number of doubling steps gives twice a square. Applying A003961 to any 2*square gives 3*(some square) which is always of the form 4k+3. Moreover, after any such "wrong turn" in A005940-tree no square nor twice a square can ever be encountered under any of the further descendants, because with this process it is impossible to find a pair for the lone prime factor now present. On the other hand, when turning left from any (2^2k)*s (where s is a square), one again gets a square of the form (3^2k)*A003961(s). All this implies that there are no numbers of the form 4k+3 in any trajectory leading to a square or twice a square in A005940-tree, while all trajectories to any other kind of number contain at least one number of the form 4k+3. Because each a(n) in this sequence contains enough information to count the 4k+3 numbers encountered on a A005940-trajectory to n (being 1 iff there are none), this filter matches A053866.
(End)

Examples

			When traversing from the root of binary tree A005940 from the node containing 7, one obtains path 7 -> 5 -> 3 -> 2 -> 1. Of these numbers, 7 and 3 are of the form 4k+3, while others are not, thus there are two separate runs of length 1: [1, 1]. On the other hand, when traversing from 15 as 15 -> 6 -> 3 -> 2 -> 1, again only two terms are of the form 4k+3: 15 and 3 and they are not next to each other, so we have the same two runs of one each: [1, 1], thus a(7) and a(15) are allotted the same value by the restricted growth sequence transform, which in this case is 3. Note that 3 occurs in this sequence for the first time at n=7, with A292383(7) = 5 and A278222(5) = 6 = 2^1 * 3^1, where those run lengths 1 and 1 are the prime exponents of 6.
		

Crossrefs

Programs

  • PARI
    allocatemem(2^30);
    rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om,invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om,invec[i],i); outvec[i] = u; u++ )); outvec; };
    write_to_bfile(start_offset,vec,bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
    A005940(n) = { my(p=2, t=1); n--; until(!n\=2, if((n%2), (t*=p), p=nextprime(p+1))); t }; \\ Modified from code of M. F. Hasler
    A046523(n) = { my(f=vecsort(factor(n)[, 2], , 4), p); prod(i=1, #f, (p=nextprime(p+1))^f[i]); };  \\ This function from Charles R Greathouse IV, Aug 17 2011
    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)};
    A278222(n) = A046523(A005940(1+n));
    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)))));
    write_to_bfile(1,rgs_transform(vector(16384,n,A278222(A292383(n)))),"b292583_upto16384.txt");

A292274 a(n) = A292383(A163511(n)).

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 2, 2, 0, 1, 0, 0, 4, 5, 4, 5, 0, 0, 2, 2, 0, 1, 0, 0, 8, 8, 10, 11, 8, 8, 10, 11, 0, 1, 0, 0, 4, 5, 4, 5, 0, 0, 2, 2, 0, 1, 0, 0, 16, 17, 16, 17, 20, 20, 22, 22, 16, 17, 16, 17, 20, 20, 22, 22, 0, 0, 2, 2, 0, 1, 0, 0, 8, 8, 10, 11, 8, 8, 10, 11, 0, 1, 0, 0, 4, 5, 4, 5, 0, 0, 2, 2, 0, 1, 0, 0, 32, 32, 34, 35, 32, 32, 34, 35, 40, 41, 40, 40, 44
Offset: 0

Views

Author

Antti Karttunen, Sep 16 2017

Keywords

Comments

Because A292383(n) = a(A243071(n)), the sequence works as a "masking function" where the 1-bits in a(n) (always a subset of the 1-bits in binary expansion of n) indicate which numbers are of the form 4k+3 in binary tree A005940 on that trajectory which leads from the root of the tree to the node containing A163511(n). This works because A243071(n) = A054429(A156552(n)), a bit-flipped variant of Leonid Broukhis's unary-binary encoded compressed factorization of natural numbers, A156552(n) being an inverse of Doudna map f(n) = A005940(1+n).

Examples

			A163511(18) = 54, that is, at "node address" 18 in binary tree A163511 (which is the mirror image of A005940) sits number 54. 18 in binary is "10010", which when read from left to right (after the most significant bit which is always 1) gives the directions to follow in either tree when starting from the root, so that we land in number 54. (E.g. in A005940-tree, turn right from 2, turn right from 4, turn left from 8 and then turn right from 27 and one lands in 54, this corresponds with the four lowermost bits of the code, "0010". In A163511 the sense of direction is just reversed). When one selects the numbers of the form 4k+3 from this path 1 -> 2 -> 4 -> 8 -> 27 -> 54, one sees that only one is 27, which corresponds with the second rightmost bit (which also is the only 1-bit) in the code, which can be masked with 2 (binary "10"), thus a(18) = 2.
A163511(15) = 7, that is, at "node address" 15 in binary tree A163511 sits number 7. 15 in binary is "1111", which tells that 7 can be located in mirror-image tree A005940 by going (after the initial root 1 and 2) three steps towards left from 2: 1 -> 2 -> 3 -> 5 -> 7. Of these numbers, only 3 and 7 are of the form 4k+3, thus the mask with which to obtain the corresponding bits from "1111" is "00101" (5 in binary), thus a(15) = 5.
A163511(31) = 11, that is, at "node address" 31 in binary tree A163511 sits number 11. 31 in binary is "11111", which tells that 11 can be located in mirror-image tree A005940 by going (after the initial root 1 and 2) four steps towards left from 2: 1 -> 2 -> 3 -> 5 -> 7 -> 11. Of these numbers, only 3, 7 and 11 are of the form 4k+3, thus the mask with which to obtain the corresponding bits from "11111" is "001011" (11 in binary), thus a(31) = 11.
		

Crossrefs

Differs from related A292592 for the first time at n=31, where a(31) = 11, while A292592(31) = 10. Compare also the scatter plots.

Programs

  • Mathematica
    f[n_] := Reverse@ Map[Ceiling[(Length@ # - 1)/2] &, DeleteCases[Split@ Join[Riffle[IntegerDigits[n, 2], 0], {0}], {k__} /; k == 1]]; Map[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]], #, # > 1 &] /. k_ /; IntegerQ@ k :> If[Mod[k, 4] == 3, 1, 0], 2] &, {1}~Join~Table[Function[t, Prime[t] Product[Prime[m]^(f[n][[m]]), {m, t}]][DigitCount[n, 2, 1]], {n, 120}]] (* Michael De Vlieger, Sep 22 2017 *)

Formula

a(n) = A292383(A163511(n)).
a(n) + A292271(n) = n, a(n) AND A292271(n) = 0.
a(n) AND n = a(n), where AND is bitwise-AND (A004198).

Extensions

Comments and examples from Antti Karttunen, Sep 22 2017

A336120 a(n) = A292383(A122111(n)).

Original entry on oeis.org

0, 0, 0, 1, 0, 2, 0, 2, 0, 4, 0, 4, 0, 8, 0, 5, 0, 5, 0, 8, 0, 16, 0, 10, 1, 32, 0, 16, 0, 10, 0, 11, 0, 64, 2, 8, 0, 128, 0, 20, 0, 20, 0, 32, 0, 256, 0, 22, 0, 8, 0, 64, 0, 11, 4, 40, 0, 512, 0, 16, 0, 1024, 0, 22, 8, 40, 0, 128, 0, 16, 0, 20, 0, 2048, 1, 256, 0, 80, 0, 44, 0, 4096, 0, 32, 16, 8192, 0, 80, 0, 22, 0, 512, 0, 16384, 32, 44, 0, 17, 0, 17, 0
Offset: 1

Views

Author

Antti Karttunen, Jul 14 2020

Keywords

Crossrefs

Programs

  • PARI
    \\ Uses also code given in A336124:
    A253553(n) = if(n<=2,1,my(f=factor(n), k=#f~); if(f[k,2]>1,f[k,2]--,f[k,1] = precprime(f[k,1]-1)); factorback(f));
    A336120(n) = if(1==n,0,(3==A336124(n))+(2*A336120(A253553(n))));

Formula

a(1) = 0, and for n > 1, a(n) = [A122111(n) == 3 (mod 4)] + 2*a(A253553(n)).
a(n) = A292383(A122111(n)).
a(n) = A253566(n) - A336125(n).
A000120(a(n)) = A336121(n).

A163511 a(0)=1. a(n) = p(A000120(n)) * Product_{m=1..A000120(n)} p(m)^A163510(n,m), where p(m) is the m-th prime.

Original entry on oeis.org

1, 2, 4, 3, 8, 9, 6, 5, 16, 27, 18, 25, 12, 15, 10, 7, 32, 81, 54, 125, 36, 75, 50, 49, 24, 45, 30, 35, 20, 21, 14, 11, 64, 243, 162, 625, 108, 375, 250, 343, 72, 225, 150, 245, 100, 147, 98, 121, 48, 135, 90, 175, 60, 105, 70, 77, 40, 63, 42, 55, 28, 33, 22, 13, 128
Offset: 0

Views

Author

Leroy Quet, Jul 29 2009

Keywords

Comments

This is a permutation of the positive integers.
From Antti Karttunen, Jun 20 2014: (Start)
Note the indexing: the domain starts from 0, while the range excludes zero, thus this is neither a bijection on the set of nonnegative integers nor on the set of positive natural numbers, but a bijection from the former set to the latter.
Apart from that discrepancy, this could be viewed as yet another "entanglement permutation" where the two complementary pairs to be interwoven together are even and odd numbers (A005843/A005408) which are entangled with the complementary pair even numbers (taken straight) and odd numbers in the order they appear in A003961: (A005843/A003961). See also A246375 which has almost the same recurrence.
Note how the even bisection halved gives the same sequence back. (For a(0)=1, take ceiling of 1/2).
(End)
From Antti Karttunen, Dec 30 2017: (Start)
This irregular table can be represented as a binary tree. Each child to the left is obtained by doubling the parent, and each child to the right is obtained by applying A003961 to the parent:
1
|
...................2...................
4 3
8......../ \........9 6......../ \........5
/ \ / \ / \ / \
/ \ / \ / \ / \
/ \ / \ / \ / \
16 27 18 25 12 15 10 7
32 81 54 125 36 75 50 49 24 45 30 35 20 21 14 11
etc.
Sequence A005940 is obtained by scanning the same tree level by level in mirror image fashion. Also in binary trees A253563 and A253565 the terms on level of the tree are some permutation of the terms present on the level n of this tree. A252464(n) gives the distance of n from 1 in all these trees, and A252463 gives the parent of the node containing n.
A252737(n) gives the sum and A252738(n) the product of terms on row n (where 1 is on row 0, 1 on row 1, 3 and 4 on row 2, etc.). A252745(n) gives the number of nodes on level n whose left child is smaller than the right child, and A252744(n) is an indicator function for those nodes.
(End)
Note that the idea behind maps like this (and the mirror image A005940) admits also using alternative orderings of primes, not just standard magnitude-wise ordering (A000040). For example, A332214 is a similar sequence but with primes rearranged as in A332211, and A332817 is obtained when primes are rearranged as in A108546. - Antti Karttunen, Mar 11 2020
From Lorenzo Sauras Altuzarra, Nov 28 2020: (Start)
This sequence is generated from A228351 by applying the following procedure: 1) eliminate the compositions that end in one unless the first one, 2) subtract one unit from every component, 3) replace every tuple [t_1, ..., t_r] by Product_{k=1..r} A000040(k)^(t_k) (see the examples).
Is it true that a(n) = A337909(n+1) if and only if a(n+1) is not a term of A161992?
Does this permutation have any other cycle apart from (1), (2) and (6, 9, 16, 7)? (End)
From Antti Karttunen, Jul 25 2023: (Start)
(In the above question, it is assumed that the starting offset would be 1 instead of 0).
Questions:
Does a(n) = 1+A054429(n) hold only when n is of the form 2^k times 1, 3 or 7, i.e., one of the terms of A029748?
It seems that A007283 gives all fixed points of map n -> a(n), like A335431 seems to give all fixed points of map n -> A332214(n). Is there a general rule for mappings like these that the fixed points (if they exist) must be of the form 2^k times a certain kind of prime, i.e., that any odd composite (times 2^k) can certainly be excluded? See also note in A029747.
(End)
If the conjecture given in A364297 holds, then it implies the above conjecture about A007283. See also A364963. - Antti Karttunen, Sep 06 2023
Conjecture: a(n^k) is never of the form x^k, for any integers n > 0, k > 1, x >= 1. This holds at least for squares, cubes, seventh and eleventh powers (see A365808, A365801, A366287 and A366391). - Antti Karttunen, Sep 24 2023, Oct 10 2023.
See A365805 for why the above holds for any n^k, with k > 1. - Antti Karttunen, Nov 23 2023

Examples

			For n=3, whose binary representation is "11", we have A000120(3)=2, with A163510(3,1) = A163510(3,2) = 0, thus a(3) = p(2) * p(1)^0 * p(2)^0 = 3*1*1 = 3.
For n=9, "1001" in binary, we have A000120(9)=2, with A163510(9,1) = 0 and A163510(9,2) = 2, thus a(9) = p(2) * p(1)^0 * p(2)^2 = 3*1*9 = 27.
For n=10, "1010" in binary, we have A000120(10)=2, with A163510(10,1) = 1 and A163510(10,2) = 1, thus a(10) = p(2) * p(1)^1 * p(2)^1 = 3*2*3 = 18.
For n=15, "1111" in binary, we have A000120(15)=4, with A163510(15,1) = A163510(15,2) = A163510(15,3) = A163510(15,4) = 0, thus a(15) = p(4) * p(1)^0 * p(2)^0 * p(3)^0 * p(4)^0 = 7*1*1*1*1 = 7.
[1], [2], [1,1], [3], [1,2], [2,1] ... -> [1], [2], [3], [1,2], ... -> [0], [1], [2], [0,1], ... -> 2^0, 2^1, 2^2, 2^0*3^1, ... = 1, 2, 4, 3, ... - _Lorenzo Sauras Altuzarra_, Nov 28 2020
		

Crossrefs

Inverse: A243071.
Cf. A007283 (known positions where a(n)=n), A029747, A029748, A364255 [= gcd(n,a(n))], A364258 [= a(n)-n], A364287 (where a(n) < n), A364292 (where a(n) <= n), A364494 (where n|a(n)), A364496 (where a(n)|n), A364963, A364297.
Cf. A365808 (positions of squares), A365801 (of cubes), A365802 (of fifth powers), A365805 [= A052409(a(n))], A366287, A366391.
Cf. A005940, A332214, A332817, A366275 (variants).

Programs

  • Mathematica
    f[n_] := Reverse@ Map[Ceiling[(Length@ # - 1)/2] &, DeleteCases[Split@ Join[Riffle[IntegerDigits[n, 2], 0], {0}], {k__} /; k == 1]]; {1}~Join~
    Table[Function[t, Prime[t] Product[Prime[m]^(f[n][[m]]), {m, t}]][DigitCount[n, 2, 1]], {n, 120}] (* Michael De Vlieger, Jul 25 2016 *)
  • Python
    from sympy import prime
    def A163511(n):
        if n:
            k, c, m = n, 0, 1
            while k:
                c += 1
                m *= prime(c)**(s:=(~k&k-1).bit_length())
                k >>= s+1
            return m*prime(c)
        return 1 # Chai Wah Wu, Jul 17 2023

Formula

For n >= 1, a(2n) is even, a(2n+1) is odd. a(2^k) = 2^(k+1), for all k >= 0.
From Antti Karttunen, Jun 20 2014: (Start)
a(0) = 1, a(1) = 2, a(2n) = 2*a(n), a(2n+1) = A003961(a(n)).
As a more general observation about the parity, we have:
For n >= 1, A007814(a(n)) = A135523(n) = A007814(n) + A209229(n). [This permutation preserves the 2-adic valuation of n, except when n is a power of two, in which cases that value is incremented by one.]
For n >= 1, A055396(a(n)) = A091090(n) = A007814(n+1) + 1 - A036987(n).
For n >= 1, a(A000225(n)) = A000040(n).
(End)
From Antti Karttunen, Oct 11 2014: (Start)
As a composition of related permutations:
a(n) = A005940(1+A054429(n)).
a(n) = A064216(A245612(n))
a(n) = A246681(A246378(n)).
Also, for all n >= 0, it holds that:
A161511(n) = A243503(a(n)).
A243499(n) = A243504(a(n)).
(End)
More linking identities from Antti Karttunen, Dec 30 2017: (Start)
A046523(a(n)) = A278531(n). [See also A286531.]
A278224(a(n)) = A285713(n). [Another filter-sequence.]
A048675(a(n)) = A135529(n) seems to hold for n >= 1.
A250245(a(n)) = A252755(n).
A252742(a(n)) = A252744(n).
A245611(a(n)) = A253891(n).
A249824(a(n)) = A275716(n).
A292263(a(n)) = A292264(n). [A292944(n) + A292264(n) = n.]
--
A292383(a(n)) = A292274(n).
A292385(a(n)) = A292271(n). [A292271(n) + A292274(n) = n.]
--
A292941(a(n)) = A292942(n).
A292943(a(n)) = A292944(n).
A292945(a(n)) = A292946(n). [A292942(n) + A292944(n) + A292946(n) = n.]
--
A292253(a(n)) = A292254(n).
A292255(a(n)) = A292256(n). [A292944(n) + A292254(n) + A292256(n) = n.]
--
A279339(a(n)) = A279342(n).
a(A071574(n)) = A269847(n).
a(A279341(n)) = A279338(n).
a(A252756(n)) = A250246(n).
(1+A008836(a(n)))/2 = A059448(n).
(End)
From Antti Karttunen, Jul 26 2023: (Start)
For all n >= 0, a(A007283(n)) = A007283(n).
A001222(a(n)) = A290251(n).
(End)

Extensions

More terms computed and examples added by Antti Karttunen, Jun 20 2014

A028982 Squares and twice squares.

Original entry on oeis.org

1, 2, 4, 8, 9, 16, 18, 25, 32, 36, 49, 50, 64, 72, 81, 98, 100, 121, 128, 144, 162, 169, 196, 200, 225, 242, 256, 288, 289, 324, 338, 361, 392, 400, 441, 450, 484, 512, 529, 576, 578, 625, 648, 676, 722, 729, 784, 800, 841, 882, 900, 961, 968, 1024
Offset: 1

Views

Author

Keywords

Comments

Numbers n such that sum of divisors of n (A000203) is odd.
Also the numbers with an odd number of run sums (trapezoidal arrangements, number of ways of being written as the difference of two triangular numbers). - Ron Knott, Jan 27 2003
Pell(n)*Sum_{k|n} 1/Pell(k) is odd, where Pell(n) is A000129(n). - Paul Barry, Oct 12 2005
Number of odd divisors of n (A001227) is odd. - Vladeta Jovovic, Aug 28 2007
A071324(a(n)) is odd. - Reinhard Zumkeller, Jul 03 2008
Sigma(a(n)) = A000203(a(n)) = A152677(n). - Jaroslav Krizek, Oct 06 2009
Numbers n such that sum of odd divisors of n (A000593) is odd. - Omar E. Pol, Jul 05 2016
A187793(a(n)) is odd. - Timothy L. Tiffin, Jul 18 2016
If k is odd (k = 2m+1 for m >= 0), then 2^k = 2^(2m+1) = 2*(2^m)^2. If k is even (k = 2m for m >= 0), then 2^k = 2^(2m) = (2^m)^2. So, the powers of 2 sequence (A000079) is a subsequence of this one. - Timothy L. Tiffin, Jul 18 2016
Numbers n such that A175317(n) = Sum_{d|n} pod(d) is odd, where pod(m) = the product of divisors of m (A007955). - Jaroslav Krizek, Dec 28 2016
Positions of zeros in A292377 and A292383, positions of ones in A286357 and A292583. (See A292583 for why.) - Antti Karttunen, Sep 25 2017
Numbers of the form A000079(i)*A016754(j), i,j>=0. - R. J. Mathar, May 30 2020
Equivalently, numbers whose odd part is square. Cf. A042968. - Peter Munn, Jul 14 2020
These are the Heinz numbers of the partitions counted by A119620. - Gus Wiseman, Oct 29 2021
Numbers m whose abundance, A033880(m), is odd. - Peter Munn, May 23 2022
Numbers with an odd number of middle divisors (cf. A067742). - Omar E. Pol, Aug 02 2022

Crossrefs

Complement of A028983.
Characteristic function is A053866, A093709.
Odd terms in A178910.
Supersequence of A000079.

Programs

  • Haskell
    import Data.List.Ordered (union)
    a028982 n = a028982_list !! (n-1)
    a028982_list = tail $ union a000290_list a001105_list
    -- Reinhard Zumkeller, Jun 27 2015
    
  • Mathematica
    Take[ Sort[ Flatten[ Table[{n^2, 2n^2}, {n, 35}] ]], 57] (* Robert G. Wilson v, Aug 27 2004 *)
  • PARI
    list(lim)=vecsort(concat(vector(sqrtint(lim\1),i,i^2), vector(sqrtint(lim\2),i,2*i^2))) \\ Charles R Greathouse IV, Jun 16 2011
    
  • Python
    from itertools import count, islice
    from sympy.ntheory.primetest import is_square
    def A028982_gen(startvalue=1): # generator of terms >= startvalue
        return filter(lambda n:int(is_square(n) or is_square(n<<1)),count(max(startvalue,1)))
    A028982_list = list(islice(A028982_gen(),30)) # Chai Wah Wu, Jan 09 2023
    
  • Python
    from math import isqrt
    def A028982(n):
        def f(x): return n-1+x-isqrt(x)-isqrt(x>>1)
        kmin, kmax = 1,2
        while f(kmax) >= kmax:
            kmax <<= 1
        while True:
            kmid = kmax+kmin>>1
            if f(kmid) < kmid:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return kmax # Chai Wah Wu, Aug 22 2024

Formula

a(n) is asymptotic to c*n^2 with c = 2/(1+sqrt(2))^2 = 0.3431457.... - Benoit Cloitre, Sep 17 2002
In particular, a(n) = c*n^2 + O(n). - Charles R Greathouse IV, Jan 11 2013
a(A003152(n)) = n^2; a(A003151(n)) = 2*n^2. - Enrique Pérez Herrero, Oct 09 2013
Sum_{n>=1} 1/a(n) = Pi^2/4. - Amiram Eldar, Jun 28 2020

A243071 Permutation of nonnegative integers: a(1) = 0, a(2) = 1, a(2n) = 2*a(n), a(2n+1) = 1 + 2*a(A064989(2n+1)).

Original entry on oeis.org

0, 1, 3, 2, 7, 6, 15, 4, 5, 14, 31, 12, 63, 30, 13, 8, 127, 10, 255, 28, 29, 62, 511, 24, 11, 126, 9, 60, 1023, 26, 2047, 16, 61, 254, 27, 20, 4095, 510, 125, 56, 8191, 58, 16383, 124, 25, 1022, 32767, 48, 23, 22, 253, 252, 65535, 18, 59, 120, 509, 2046, 131071
Offset: 1

Views

Author

Antti Karttunen, Jun 20 2014

Keywords

Comments

Note the indexing: the domain starts from 1, while the range includes also zero.
See also the comments at A163511, which is the inverse permutation to this one.

Crossrefs

Inverse: A163511.
Cf. A000040, A000225, A007814, A054429, A064989, A064216, A122111, A209229, A245611 (= (a(2n-1)-1)/2, for n > 1), A245612, A292383, A292385, A297171 (Möbius transform).
Cf. A007283 (known positions where a(n)=n), A364256 [= gcd(n,a(n))], A364288 [= n-a(n)], A364289 [where a(n)>=n], A364290 [where a(n)A364291 [where a(n)<=n], A364497 [where n|a(n)].
Cf. A156552 (variant with inverted binary code), A253566, A332215, A332811, A334859 (other variants).

Programs

  • 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)};
    A243071(n) = if(n<=2, n-1, if(!(n%2), 2*A243071(n/2), 1+(2*A243071(A064989(n))))); \\ Antti Karttunen, Jul 18 2020
    
  • PARI
    A243071(n) = if(n<=2, n-1, 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]); ((3<<#binary(res\2))-res-1)); \\ (Combining programs given in A156552 and A054429) - Antti Karttunen, Jul 28 2023
    
  • Python
    from functools import reduce
    from sympy import factorint, prevprime
    from operator import mul
    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 a(n): return n - 1 if n<3 else 2*a(n//2) if n%2==0 else 1 + 2*a(a064989(n))
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 15 2017
  • Scheme
    ;; With memoizing definec-macro from Antti Karttunen's IntSeq-library.
    (definec (A243071 n) (cond ((<= n 2) (- n 1)) ((even? n) (* 2 (A243071 (/ n 2)))) (else (+ 1 (* 2 (A243071 (A064989 n)))))))
    

Formula

a(1) = 0, a(2) = 1, a(2n) = 2*a(n), a(2n+1) = 1 + 2*a(A064989(2n+1)).
For n >= 1, a(A000040(n)) = A000225(n).
For n >= 1, a(2n+1) = 1 + 2*a(A064216(n+1)).
From Antti Karttunen, Jul 18 2020: (Start)
a(n) = A245611(A048673(n)).
a(n) = A253566(A122111(n)).
a(n) = A334859(A225546(n)).
For n >= 2, a(n) = A054429(A156552(n)).
a(n) = A292383(n) + A292385(n) = A292383(n) OR A292385(n).
For n > 1, A007814(a(n)) = A007814(n) - A209229(n). [This map preserves the 2-adic valuation of n, except when n is a power of two, in which cases it is decremented by one.]
(End)

A292385 a(1) = 0, a(2) = 1, and for n > 2, a(n) = 2*a(A252463(n)) + [n == 1 (mod 4)].

Original entry on oeis.org

0, 1, 2, 2, 5, 4, 10, 4, 5, 10, 20, 8, 41, 20, 8, 8, 83, 10, 166, 20, 21, 40, 332, 16, 11, 82, 8, 40, 665, 16, 1330, 16, 41, 166, 16, 20, 2661, 332, 80, 40, 5323, 42, 10646, 80, 17, 664, 21292, 32, 23, 22, 164, 164, 42585, 16, 42, 80, 333, 1330, 85170, 32, 170341, 2660, 40, 32, 83, 82, 340682, 332, 665, 32, 681364, 40, 1362729, 5322, 20, 664, 33, 160
Offset: 1

Views

Author

Antti Karttunen, Sep 16 2017

Keywords

Comments

Variant of A292381. Here the most significant 1-bit is at the one step smaller position.

Crossrefs

Formula

a(1) = 0, a(2) = 1, and for n > 2, 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.
For n >= 1, a(n) + A292383(n) = A243071(n); a(A163511(n)) = A292271(n).
For n >= 2, A004754(a(n)) = A292381(n).

A292377 a(1) = 0, and for n > 1, a(n) = a(A252463(n)) + [n == 3 (mod 4)].

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 17 2017

Keywords

Comments

For numbers > 1, iterate the map x -> A252463(x) which divides even numbers by 2 and shifts every prime in the prime factorization of odd n one index step towards smaller primes. a(n) counts the numbers of the form 4k+3 encountered until 1 has been reached. The count includes also n itself if it is of the form 4k+3 (A004767).
In other words, locate the node which contains n in binary tree A005940 and traverse from that node towards the root, counting all numbers of the form 4k+3 that occur on the path.

Crossrefs

Programs

  • Mathematica
    a[1] = 0; a[n_] := a[n] = a[Which[n == 1, 1, EvenQ@ n, n/2, True, Times @@ Power[Which[# == 1, 1, # == 2, 1, True, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger@ n]] + Boole[Mod[n, 4] == 3]; Array[a, 105]

Formula

a(1) = 0, and for n > 1, a(n) = a(A252463(n)) + floor((n mod 4)/3).
Equivalently, a(2n) = a(n), and for odd numbers n > 1, a(n) = a(A064989(n)) + [n == 3 (mod 4)].
a(n) = A000120(A292383(n)).
Other identities. For n >= 1:
a(n) >= A292376(n).
a(A000040(n)) = A267098(n).
1 + a(n) - A292375(n) = A292378(n).
For n >= 2, a(n) + A292375(n) = A061395(n).

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

A292244 Base-2 expansion of a(n) encodes the steps where multiples of 3 are encountered when map x -> A253889(x) is iterated down to 1, starting from x=n.

Original entry on oeis.org

0, 0, 1, 0, 0, 3, 0, 2, 5, 0, 0, 1, 0, 0, 1, 12, 6, 7, 14, 0, 1, 0, 4, 1, 8, 10, 3, 0, 0, 21, 24, 0, 1, 28, 2, 3, 2, 0, 1, 0, 0, 5, 2, 2, 1, 22, 24, 17, 0, 12, 33, 32, 14, 35, 42, 28, 45, 24, 0, 1, 16, 2, 11, 48, 0, 59, 0, 8, 3, 0, 2, 5, 0, 16, 1, 4, 20, 3, 6, 6, 7, 8, 0, 1, 56, 0, 3, 0, 42, 5, 0, 48, 5, 0, 0, 1, 14, 2, 65, 64, 56, 49, 44, 4, 49, 64, 6, 57, 0
Offset: 1

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			For n = 3, the starting value is a multiple of three, after which follows A253889(3) = 1, the end point of iteration, which is not a multiple of three, thus a(3) = 1*(2^0) = 1.
For n = 8, the starting value is not a multiple of three, after which follows A253889(8) = 3, which is, thus a(8) = 0*(2^0) + 1*(2^1) = 2.
For n = 9, the starting value is a multiple of three, after which follows A253889(9) = 8 (which is not), while A253889(8) = 3 (which is), thus a(9) = 1*(2^0) + 0*(2^1) + 1*(2^2) = 5.
		

Crossrefs

Cf. also A292245, A292246, and A292381, A292383, A292385, and A292590, A292591 for similarly constructed sequences, and also A292250.

Programs

  • Mathematica
    f[n_] := Times @@ Power[If[# == 1, 1, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger[2 n - 1];g[n_] := (Times @@ Power[If[# == 1, 1, NextPrime@ #] & /@ First@ #, Last@ #] + 1)/2 &@ Transpose@ FactorInteger@ n;Table[FromDigits[#, 2] &@ Map[Boole[Divisible[#, 3]] &,  Reverse@ NestWhileList[Floor@ g[Floor[f[#]/2]] &, n, # > 1 &]], {n, 109}] (* Michael De Vlieger, Sep 16 2017 *)
  • Scheme
    (define (A292244 n) (A291770 (A292243 n)))

Formula

a(n) = A291770(A292243(n)).
Other identities. For all n >= 1:
a(A048673(n)) = A292247(n).
a(n) + A292245(n) = A064216(n).
a(n) AND A292245(n) = a(n) AND A292246(n) = 0, where AND is a bitwise-AND (A004198).
Showing 1-10 of 24 results. Next