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.

A001358 Semiprimes (or biprimes): products of two primes.

Original entry on oeis.org

4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95, 106, 111, 115, 118, 119, 121, 122, 123, 129, 133, 134, 141, 142, 143, 145, 146, 155, 158, 159, 161, 166, 169, 177, 178, 183, 185, 187
Offset: 1

Views

Author

Keywords

Comments

Numbers of the form p*q where p and q are primes, not necessarily distinct.
These numbers are sometimes called semiprimes or 2-almost primes.
Numbers n such that Omega(n) = 2 where Omega(n) = A001222(n) is the sum of the exponents in the prime decomposition of n.
Complement of A100959; A064911(a(n)) = 1. - Reinhard Zumkeller, Nov 22 2004
The graph of this sequence appears to be a straight line with slope 4. However, the asymptotic formula shows that the linearity is an illusion and in fact a(n)/n ~ log(n)/log(log(n)) goes to infinity. See also the graph of A066265 = number of semiprimes < 10^n.
For numbers between 33 and 15495, semiprimes are more plentiful than any other k-almost prime. See A125149.
Numbers that are divisible by exactly 2 prime powers (not including 1). - Jason Kimberley, Oct 02 2011
The (disjoint) union of A006881 and A001248. - Jason Kimberley, Nov 11 2015
An equivalent definition of this sequence is a'(n) = smallest composite number which is not divided by any smaller composite number a'(1),...,a'(n-1). - Meir-Simchah Panzer, Jun 22 2016
The above characterization can be simplified to "Composite numbers not divisible by a smaller term." This shows that this is the equivalent of primes computed via Eratosthenes's sieve, but starting with the set of composite numbers (i.e., complement of 1 union primes) instead of all positive integers > 1. It's easy to see that iterating the method (using Eratosthenes's sieve each time on the remaining numbers, complement of the previously computed set) yields numbers with bigomega = k for k = 0, 1, 2, 3, ..., i.e., {1}, A000040, this, A014612, etc. - M. F. Hasler, Apr 24 2019
For all n except n = 2, a(n) is a deficient number. - Amrit Awasthi, Sep 10 2024
It is reasonable to assume that the "comforting numbers" which John T. Williams found in Chapter 3 of Milne's book "The House at Pooh Corner" are these semiprimes. Winnie-the-Pooh wonders whether he has 14 or 15 honey pots and concludes: "It's sort of comforting." To arrange a semiprime number of honey pots in a rectangular way, let's say on a shelf, with the larger divisor parallel to the wall, there is only one solution and this is for a simple mind like Winnie-the-Pooh comforting. - Ruediger Jehn, Dec 12 2024

Examples

			From _Gus Wiseman_, May 27 2021: (Start)
The sequence of terms together with their prime factors begins:
   4 = 2*2     46 = 2*23     91 = 7*13    141 = 3*47
   6 = 2*3     49 = 7*7      93 = 3*31    142 = 2*71
   9 = 3*3     51 = 3*17     94 = 2*47    143 = 11*13
  10 = 2*5     55 = 5*11     95 = 5*19    145 = 5*29
  14 = 2*7     57 = 3*19    106 = 2*53    146 = 2*73
  15 = 3*5     58 = 2*29    111 = 3*37    155 = 5*31
  21 = 3*7     62 = 2*31    115 = 5*23    158 = 2*79
  22 = 2*11    65 = 5*13    118 = 2*59    159 = 3*53
  25 = 5*5     69 = 3*23    119 = 7*17    161 = 7*23
  26 = 2*13    74 = 2*37    121 = 11*11   166 = 2*83
  33 = 3*11    77 = 7*11    122 = 2*61    169 = 13*13
  34 = 2*17    82 = 2*41    123 = 3*41    177 = 3*59
  35 = 5*7     85 = 5*17    129 = 3*43    178 = 2*89
  38 = 2*19    86 = 2*43    133 = 7*19    183 = 3*61
  39 = 3*13    87 = 3*29    134 = 2*67    185 = 5*37
(End)
		

References

  • Archimedeans Problems Drive, Eureka, 17 (1954), 8.
  • Raymond Ayoub, An Introduction to the Analytic Theory of Numbers, Amer. Math. Soc., 1963; Chapter II, Problem 60.
  • Edmund Landau, Handbuch der Lehre von der Verteilung der Primzahlen, Vol. 1, Teubner, Leipzig; third edition: Chelsea, New York (1974). See p. 211.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • John T. Williams, Pooh and the Philosophers, Dutton Books, 1995.

Crossrefs

Cf. A064911 (characteristic function).
Cf. A048623, A048639, A000040 (primes), A014612 (products of 3 primes), A014613, A014614, A072000 ("pi" for semiprimes), A065516 (first differences).
Sequences listing r-almost primes, that is, the n such that A001222(n) = r: A000040 (r=1), this sequence (r=2), A014612 (r=3), A014613 (r=4), A014614 (r=5), A046306 (r=6), A046308 (r=7), A046310 (r=8), A046312 (r=9), A046314 (r=10), A069272 (r=11), A069273 (r=12), A069274 (r=13), A069275 (r=14), A069276 (r=15), A069277 (r=16), A069278 (r=17), A069279 (r=18), A069280 (r=19), A069281 (r=20).
These are the Heinz numbers of length-2 partitions, counted by A004526.
The squarefree case is A006881 with odd/even terms A046388/A100484 (except 4).
Including primes gives A037143.
The odd/even terms are A046315/A100484.
Partial sums are A062198.
The prime factors are A084126/A084127.
Grouping by greater factor gives A087112.
The product/sum/difference of prime indices is A087794/A176504/A176506.
Positions of even/odd terms are A115392/A289182.
The terms with relatively prime/divisible prime indices are A300912/A318990.
Factorizations using these terms are counted by A320655.
The prime indices are A338898/A338912/A338913.
Grouping by weight (sum of prime indices) gives A338904, with row sums A024697.
The terms with even/odd weight are A338906/A338907.
The terms with odd/even prime indices are A338910/A338911.
The least/greatest term of weight n is A339114/A339115.

Programs

  • Haskell
    a001358 n = a001358_list !! (n-1)
    a001358_list = filter ((== 2) . a001222) [1..]
    
  • Magma
    [n: n in [2..200] | &+[d[2]: d in Factorization(n)] eq 2]; // Bruno Berselli, Sep 09 2015
    
  • Maple
    A001358 := proc(n) option remember; local a; if n = 1 then 4; else for a from procname(n-1)+1 do if numtheory[bigomega](a) = 2 then return a; end if; end do: end if; end proc:
    seq(A001358(n), n=1..120) ; # R. J. Mathar, Aug 12 2010
  • Mathematica
    Select[Range[200], Plus@@Last/@FactorInteger[#] == 2 &] (* Zak Seidov, Jun 14 2005 *)
    Select[Range[200], PrimeOmega[#]==2&] (* Harvey P. Dale, Jul 17 2011 *)
  • PARI
    select( isA001358(n)={bigomega(n)==2}, [1..199]) \\ M. F. Hasler, Apr 09 2008; added select() Apr 24 2019
    
  • PARI
    list(lim)=my(v=List(),t);forprime(p=2, sqrt(lim), t=p;forprime(q=p, lim\t, listput(v,t*q))); vecsort(Vec(v)) \\ Charles R Greathouse IV, Sep 11 2011
    
  • PARI
    A1358=List(4); A001358(n)={while(#A1358M. F. Hasler, Apr 24 2019
    
  • Python
    from sympy import factorint
    def ok(n): return sum(factorint(n).values()) == 2
    print([k for k in range(1, 190) if ok(k)]) # Michael S. Branicky, Apr 30 2022
    
  • Python
    from math import isqrt
    from sympy import primepi, prime
    def A001358(n):
        def f(x): return int(n+x-sum(primepi(x//prime(k))-k+1 for k in range(1, primepi(isqrt(x))+1)))
        m, k = n, f(n)
        while m != k:
            m, k = k, f(k)
        return m # Chai Wah Wu, Jul 23 2024

Formula

a(n) ~ n*log(n)/log(log(n)) as n -> infinity [Landau, p. 211], [Ayoub].
Recurrence: a(1) = 4; for n > 1, a(n) = smallest composite number which is not a multiple of any of the previous terms. - Amarnath Murthy, Nov 10 2002
A174956(a(n)) = n. - Reinhard Zumkeller, Apr 03 2010
a(n) = A088707(n) - 1. - Reinhard Zumkeller, Feb 20 2012
Sum_{n>=1} 1/a(n)^s = (1/2)*(P(s)^2 + P(2*s)), where P is the prime zeta function. - Enrique Pérez Herrero, Jun 24 2012
sigma(a(n)) + phi(a(n)) - mu(a(n)) = 2*a(n) + 1. mu(a(n)) = ceiling(sqrt(a(n))) - floor(sqrt(a(n))). - Wesley Ivan Hurt, May 21 2013
mu(a(n)) = -Omega(a(n)) + omega(a(n)) + 1, where mu is the Moebius function (A008683), Omega is the count of prime factors with repetition, and omega is the count of distinct prime factors. - Alonso del Arte, May 09 2014
a(n) = A078840(2,n). - R. J. Mathar, Jan 30 2019
A100484 UNION A046315. - R. J. Mathar, Apr 19 2023
Conjecture: a(n)/n ~ (log(n)/log(log(n)))*(1-(M/log(log(n)))) as n -> oo, where M is the Mertens's constant (A077761). - Alain Rocchelli, Feb 02 2025

Extensions

More terms from James Sellers, Aug 22 2000

A048675 If n = p_i^e_i * ... * p_k^e_k, p_i < ... < p_k primes (with p_i = prime(i)), then a(n) = (1/2) * (e_i * 2^i + ... + e_k * 2^k).

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 8, 3, 4, 5, 16, 4, 32, 9, 6, 4, 64, 5, 128, 6, 10, 17, 256, 5, 8, 33, 6, 10, 512, 7, 1024, 5, 18, 65, 12, 6, 2048, 129, 34, 7, 4096, 11, 8192, 18, 8, 257, 16384, 6, 16, 9, 66, 34, 32768, 7, 20, 11, 130, 513, 65536, 8, 131072, 1025, 12, 6, 36, 19
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

The original motivation for this sequence was to encode the prime factorization of n in the binary representation of a(n), each such representation being unique as long as this map is restricted to A005117 (squarefree numbers, resulting a permutation of nonnegative integers A048672) or any of its subsequence, resulting an injective function like A048623 and A048639.
However, also the restriction to A260443 (not all terms of which are squarefree) results a permutation of nonnegative integers, namely A001477, the identity permutation.
When a polynomial with nonnegative integer coefficients is encoded with the prime factorization of n (e.g., as in A206296, A260443), then a(n) gives the evaluation of that polynomial at x=2.
The primitive completely additive integer sequence that satisfies a(n) = a(A225546(n)), n >= 1. By primitive, we mean that if b is another such sequence, then there is an integer k such that b(n) = k * a(n) for all n >= 1. - Peter Munn, Feb 03 2020
If the binary rank of an integer partition y is given by Sum_i 2^(y_i-1), and the Heinz number is Product_i prime(y_i), then a(n) is the binary rank of the integer partition with Heinz number n. Note the function taking a set s to Sum_i 2^(s_i-1) is the inverse of A048793 (binary indices), and the function taking a multiset m to Product_i prime(m_i) is the inverse of A112798 (prime indices). - Gus Wiseman, May 22 2024

Examples

			From _Gus Wiseman_, May 22 2024: (Start)
The A018819(7) = 6 cases of binary rank 7 are the following, together with their prime indices:
   30: {1,2,3}
   40: {1,1,1,3}
   54: {1,2,2,2}
   72: {1,1,1,2,2}
   96: {1,1,1,1,1,2}
  128: {1,1,1,1,1,1,1}
(End)
		

Crossrefs

Row 2 of A104244.
Similar logarithmic functions: A001414, A056239, A090880, A289506, A293447.
Left inverse of the following sequences: A000079, A019565, A038754, A068911, A134683, A260443, A332824.
A003961, A028234, A032742, A055396, A064989, A067029, A225546, A297845 are used to express relationship between terms of this sequence.
Cf. also A048623, A048676, A099884, A277896 and tables A277905, A285325.
Cf. A297108 (Möbius transform), A332813 and A332823 [= a(n) mod 3].
Pairs of sequences (f,g) that satisfy a(f(n)) = g(n), possibly with offset change: (A000203,A331750), (A005940,A087808), (A007913,A248663), (A007947,A087207), (A097248,A048675), (A206296,A000129), (A248692,A056239), (A283477,A005187), (A284003,A006068), (A285101,A028362), (A285102,A068052), (A293214,A001065), (A318834,A051953), (A319991,A293897), (A319992,A293898), (A320017,A318674), (A329352,A069359), (A332461,A156552), (A332462,A156552), (A332825,A000010) and apparently (A163511,A135529).
See comments/formulas in A277333, A331591, A331740 giving their relationship to this sequence.
The formula section details how the sequence maps the terms of A329050, A329332.
A277892, A322812, A322869, A324573, A324575 give properties of the n-th term of this sequence.
The term k appears A018819(k) times.
The inverse transformation is A019565 (Heinz number of binary indices).
The version for distinct prime indices is A087207.
Numbers k such that a(k) is prime are A277319, counts A372688.
Grouping by image gives A277905.
A014499 lists binary indices of prime numbers.
A061395 gives greatest prime index, least A055396.
A112798 lists prime indices, length A001222, reverse A296150, sum A056239.
Binary indices:
- listed A048793, sum A029931
- reversed A272020
- opposite A371572, sum A230877
- length A000120, complement A023416
- min A001511, opposite A000012
- max A070939, opposite A070940
- complement A368494, sum A359400
- opposite complement A371571, sum A359359

Programs

  • Maple
    nthprime := proc(n) local i; if(isprime(n)) then for i from 1 to 1000000 do if(ithprime(i) = n) then RETURN(i); fi; od; else RETURN(0); fi; end; # nthprime(2) = 1, nthprime(3) = 2, nthprime(5) = 3, etc. - this is also A049084.
    A048675 := proc(n) local s,d; s := 0; for d in ifactors(n)[ 2 ] do s := s + d[ 2 ]*(2^(nthprime(d[ 1 ])-1)); od; RETURN(s); end;
    # simpler alternative
    f:= n -> add(2^(numtheory:-pi(t[1])-1)*t[2], t=ifactors(n)[2]):
    map(f, [$1..100]); # Robert Israel, Oct 10 2016
  • Mathematica
    a[1] = 0; a[n_] := Total[ #[[2]]*2^(PrimePi[#[[1]]]-1)& /@ FactorInteger[n] ]; Array[a, 100] (* Jean-François Alcover, Mar 15 2016 *)
  • PARI
    a(n) = my(f = factor(n)); sum(k=1, #f~, f[k,2]*2^primepi(f[k,1]))/2; \\ Michel Marcus, Oct 10 2016
    
  • PARI
    \\ The following program reconstructs terms (e.g. for checking purposes) from the factorization file prepared by Hans Havermann:
    v048675sigs = readvec("a048675.txt");
    A048675(n) = if(n<=2,n-1,my(prsig=v048675sigs[n],ps=prsig[1],es=prsig[2]); prod(i=1,#ps,ps[i]^es[i])); \\ Antti Karttunen, Feb 02 2020
    
  • Python
    from sympy import factorint, primepi
    def a(n):
        if n==1: return 0
        f=factorint(n)
        return sum([f[i]*2**(primepi(i) - 1) for i in f])
    print([a(n) for n in range(1, 51)]) # Indranil Ghosh, Jun 19 2017

Formula

a(1) = 0, a(n) = 1/2 * (e1*2^i1 + e2*2^i2 + ... + ez*2^iz) if n = p_{i1}^e1*p_{i2}^e2*...*p_{iz}^ez, where p_i is the i-th prime. (e.g. p_1 = 2, p_2 = 3).
Totally additive with a(p^e) = e * 2^(PrimePi(p)-1), where PrimePi(n) = A000720(n). [Missing factor e added to the comment by Antti Karttunen, Jul 29 2015]
From Antti Karttunen, Jul 29 2015: (Start)
a(1) = 0; for n > 1, a(n) = 2^(A055396(n)-1) + a(A032742(n)). [Where A055396(n) gives the index of the smallest prime dividing n and A032742(n) gives the largest proper divisor of n.]
a(1) = 0; for n > 1, a(n) = (A067029(n) * (2^(A055396(n)-1))) + a(A028234(n)).
Other identities. For all n >= 0:
a(A019565(n)) = n.
a(A260443(n)) = n.
a(A206296(n)) = A000129(n).
a(A005940(n+1)) = A087808(n).
a(A007913(n)) = A248663(n).
a(A007947(n)) = A087207(n).
a(A283477(n)) = A005187(n).
a(A284003(n)) = A006068(n).
a(A285101(n)) = A028362(1+n).
a(A285102(n)) = A068052(n).
Also, it seems that a(A163511(n)) = A135529(n) for n >= 1. (End)
a(1) = 0, a(2n) = 1+a(n), a(2n+1) = 2*a(A064989(2n+1)). - Antti Karttunen, Oct 11 2016
From Peter Munn, Jan 31 2020: (Start)
a(n^2) = a(A003961(n)) = 2 * a(n).
a(A297845(n,k)) = a(n) * a(k).
a(n) = a(A225546(n)).
a(A329332(n,k)) = n * k.
a(A329050(n,k)) = 2^(n+k).
(End)
From Antti Karttunen, Feb 02-25 2020, Feb 01 2021: (Start)
a(n) = Sum_{d|n} A297108(d) = Sum_{d|A225546(n)} A297108(d).
a(n) = a(A097248(n)).
For n >= 2:
A001221(a(n)) = A322812(n), A001222(a(n)) = A277892(n).
A000203(a(n)) = A324573(n), A033879(a(n)) = A324575(n).
For n >= 1, A331750(n) = a(A000203(n)).
For n >= 1, the following chains hold:
A293447(n) >= a(n) >= A331740(n) >= A331591(n).
a(n) >= A087207(n) >= A248663(n).
(End)
a(n) = A087207(A097248(n)). - Flávio V. Fernandes, Jul 16 2025

Extensions

Entry revised by Antti Karttunen, Jul 29 2015
More linking formulas added by Antti Karttunen, Apr 18 2017

A018900 Sums of two distinct powers of 2.

Original entry on oeis.org

3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 65, 66, 68, 72, 80, 96, 129, 130, 132, 136, 144, 160, 192, 257, 258, 260, 264, 272, 288, 320, 384, 513, 514, 516, 520, 528, 544, 576, 640, 768, 1025, 1026, 1028, 1032, 1040, 1056, 1088, 1152, 1280, 1536, 2049, 2050, 2052, 2056, 2064, 2080, 2112, 2176, 2304, 2560, 3072
Offset: 1

Views

Author

Jonn Dalton (jdalton(AT)vnet.ibm.com), Dec 11 1996

Keywords

Comments

Appears to give all k such that 8 is the highest power of 2 dividing A005148(k). - Benoit Cloitre, Jun 22 2002
Seen as a triangle read by rows, T(n,k) = 2^(k-1) + 2^n, 1 <= k <= n, the sum of the n-th row equals A087323(n). - Reinhard Zumkeller, Jun 24 2009
Numbers whose base-2 sum of digits is 2. - Tom Edgar, Aug 31 2013
All odd terms are A000051. - Robert G. Wilson v, Jan 03 2014
A239708 holds the subsequence of terms m such that m - 1 is prime. - Hieronymus Fischer, Apr 20 2014

Examples

			From _Hieronymus Fischer_, Apr 27 2014: (Start)
a(1) = 3, since 3 = 2^1 + 2^0.
a(5) = 10, since 10 = 2^3 + 2^1.
a(10^2) = 16640
a(10^3) = 35184372089344
a(10^4) = 2788273714550169769618891533295908724670464 = 2.788273714550...*10^42
a(10^5) = 3.6341936214780344527466190...*10^134
a(10^6) = 4.5332938264998904048012398...*10^425
a(10^7) = 1.6074616084721302346802429...*10^1346
a(10^8) = 1.4662184497310967196301632...*10^4257
a(10^9) = 2.3037539289782230932863807...*10^13462
a(10^10) = 9.1836811272250798973464436...*10^42571
(End)
		

Crossrefs

Cf. A000079, A014311, A014312, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 3, 4, ..., 9).
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10). - M. F. Hasler, Dec 23 2016

Programs

  • C
    unsigned hakmem175(unsigned x) {
        unsigned s, o, r;
        s = x & -x; r = x + s;
        o = x ^ r;  o = (o >> 2) / s;
        return r | o;
    }
    unsigned A018900(int n) {
        if (n == 1) return 3;
        return hakmem175(A018900(n - 1));
    } // Peter Luschny, Jan 01 2014
    
  • Haskell
    a018900 n = a018900_list !! (n-1)
    a018900_list = elemIndices 2 a073267_list  -- Reinhard Zumkeller, Mar 07 2012
    
  • Maple
    a:= n-> (i-> 2^i+2^(n-1-i*(i-1)/2))(floor((sqrt(8*n-1)+1)/2)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 01 2022
  • Mathematica
    Select[ Range[ 1056 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==2)& ]
    Union[Total/@Subsets[2^Range[0,10],{2}]] (* Harvey P. Dale, Mar 04 2012 *)
  • PARI
    for(m=1,9,for(n=0,m-1,print1(2^m+2^n", "))) \\ Charles R Greathouse IV, Sep 09 2011
    
  • PARI
    is(n)=hammingweight(n)==2 \\ Charles R Greathouse IV, Mar 03 2014
    
  • PARI
    for(n=0,10^5,if(hammingweight(n)==2,print1(n,", "))); \\ Joerg Arndt, Mar 04 2014
    
  • PARI
    a(n)= my(t=sqrtint(n*8)\/2); 2^t + 2^(n-1-t*(t-1)/2); \\ Ruud H.G. van Tol, Nov 30 2024
    
  • Python
    print([n for n in range(1, 3001) if bin(n)[2:].count("1")==2]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    A018900_list = [2**a+2**b for a in range(1,10) for b in range(a)] # Chai Wah Wu, Jan 24 2021
    
  • Python
    from math import isqrt, comb
    def A018900(n): return (1<<(m:=isqrt(n<<3)+1>>1))+(1<<(n-1-comb(m,2))) # Chai Wah Wu, Oct 30 2024
  • Smalltalk
    distinctPowersOf: b
      "Version 1: Answers the n-th number of the form b^i + b^j, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: a(n)"
      | n i j |
      n := self.
      i := (8*n - 1) sqrtTruncated + 1 // 2.
      j := n - (i*(i - 1)/2) - 1.
      ^(b raisedToInteger: i) + (b raisedToInteger: j)
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    distinctPowersOf: b
      "Version 2: Answers an array which holds the first n numbers of the form b^i + b^j, i>j>=0, where n is the receiver. b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [first n terms]"
      | k p q terms |
      terms := OrderedCollection new.
      k := 0.
      p := b.
      q := 1.
      [k < self] whileTrue:
             [[q < p and: [k < self]] whileTrue:
                       [k := k + 1.
                       terms add: p + q.
                       q := b * q].
             p := b * p.
             q := 1].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    floorDistinctPowersOf: b
      "Answers an array which holds all the numbers b^i + b^j < n, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n floorDistinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [all terms < n]"
      | a n p q terms |
      terms := OrderedCollection new.
      n := self.
      p := b.
      q := 1.
      a := p + q.
      [a < n] whileTrue:
             [[q < p and: [a < n]] whileTrue:
                       [terms add: a.
                       q := b * q.
                       a := p + q].
             p := b * p.
             q := 1.
             a := p + q].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    invertedDistinctPowersOf: b
      "Given a number m which is a distinct power of b, this method answers the index n such that there are uniquely defined i>j>=0 for which b^i + b^j = m, where m is the receiver;  b > 1 (b = 2, for this sequence).
      Usage: m invertedDistinctPowersOf: 2
      Answer: n such that a(n) = m, or, if no such n exists, min (k | a(k) >= m)"
      | n i j k m |
      m := self.
      i := m integerFloorLog: b.
      j := m - (b raisedToInteger: i) integerFloorLog: b.
      n := i * (i - 1) / 2 + 1 + j.
      ^n
    [by Hieronymus Fischer, Apr 20 2014]
    

Formula

a(n) = 2^trinv(n-1) + 2^((n-1)-((trinv(n-1)*(trinv(n-1)-1))/2)), i.e., 2^A002024(n)+2^A002262(n-1). - Antti Karttunen
a(n) = A059268(n-1) + A140513(n-1). A000120(a(n)) = 2. Complement of A161989. A151774(a(n)) = 1. - Reinhard Zumkeller, Jun 24 2009
A073267(a(n)) = 2. - Reinhard Zumkeller, Mar 07 2012
Start with A000051. If n is in sequence, then so is 2n. - Ralf Stephan, Aug 16 2013
a(n) = A057168(a(n-1)) for n>1 and a(1) = 3. - Marc LeBrun, Jan 01 2014
From Hieronymus Fischer, Apr 20 2014: (Start)
Formulas for a general parameter b according to a(n) = b^i + b^j, i>j>=0; b = 2 for this sequence.
a(n) = b^i + b^j, where i = floor((sqrt(8n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2 [for a Smalltalk implementation see Prog section, method distinctPowersOf: b (2 versions)].
a(A000217(n)) = (b + 1)*b^(n-1) = b^n + b^(n-1).
a(A000217(n)+1) = 1 + b^(n+1).
a(n + 1 + floor((sqrt(8n - 1) + 1)/2)) = b*a(n).
a(n + 1 + floor(log_b(a(n)))) = b*a(n).
a(n + 1) = b^2/(b+1) * a(n) + 1, if n is a triangular number (s. A000217).
a(n + 1) = b*a(n) + (1-b)* b^floor((sqrt(8n - 1) + 1)/2), if n is not a triangular number.
The next term can also be calculated without using the index n. Let m be a term and i = floor(log_b(m)), then:
a(n + 1) = b*m + (1-b)* b^i, if floor(log_b(m/(b+1))) + 1 < i,
a(n + 1) = b^2/(b+1) * m + 1, if floor(log_b(m/(b+1))) + 1 = i.
Partial sum:
Sum_{k=1..n} a(k) = ((((b-1)*(j+1)+i-1)*b^(i-j) + b)*b^j - i)/(b-1), where i = floor((sqrt(8*n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2.
Inverse:
For each sequence term m, the index n such that a(n) = m is determined by n := i*(i-1)/2 + j + 1, where i := floor(log_b(m)), j := floor(log_b(m - b^floor(log_b(m)))) [for a Smalltalk implementation see Prog section, method invertedDistinctPowersOf: b].
Inequalities:
a(n) <= (b+1)/b * b^floor(sqrt(2n)+1/2), equality holds for triangular numbers.
a(n) > b^floor(sqrt(2n)+1/2).
a(n) < b^sqrt(2n)*sqrt(b).
a(n) > b^sqrt(2n)/sqrt(b).
Asymptotic behavior:
lim sup a(n)/b^sqrt(2n) = sqrt(b).
lim inf a(n)/b^sqrt(2n) = 1/sqrt(b).
lim sup a(n)/b^(floor(sqrt(2n))) = b.
lim inf a(n)/b^(floor(sqrt(2n))) = 1.
lim sup a(n)/b^(floor(sqrt(2n)+1/2)) = (b+1)/b.
lim inf a(n)/b^(floor(sqrt(2n)+1/2)) = 1.
(End)
Sum_{n>=1} 1/a(n) = A179951. - Amiram Eldar, Oct 06 2020

Extensions

Edited by M. F. Hasler, Dec 23 2016

A048672 Binary encoding of squarefree numbers (A005117): A048640(n)/2.

Original entry on oeis.org

0, 1, 2, 4, 3, 8, 5, 16, 32, 9, 6, 64, 128, 10, 17, 256, 33, 512, 7, 1024, 18, 65, 12, 2048, 129, 34, 4096, 11, 8192, 257, 16384, 66, 32768, 20, 130, 513, 65536, 131072, 1025, 36, 19, 262144, 258, 13, 524288, 1048576, 2049, 24, 35, 2097152, 4097, 4194304, 68
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

Permutation of nonnegative integers. Note the indexing, the domain starts from 1, although the range includes also 0.
A246353 gives the inverse of this sequence, in a sense that a(A246353(n)) = n for all n >= 0, and A246353(a(n)) = n for all n >= 1. When one is subtracted from the latter, another permutation of nonnegative integers is obtained: A064273. - Antti Karttunen, Aug 23 2014 based on comment from Howard A. Landman, Sep 25 2001
Also index of n-th term of A019565 when its terms are sorted in increasing order. For example: a(6) = 8. The smallest values of A019565 are 1,2,3,5,6,7 . The 6th is 7 which is A019565(8). - Philippe Lallouet (philip.lallouet(AT)orange.fr), Apr 28 2008
a(n) is the number whose binary indices are the prime indices of the n-th squarefree number (row n of A329631), where a binary index of n is any position of a 1 in its reversed binary expansion, and a prime index of n is a number m such that prime(m) divides n. The binary indices of n are row n of A048793, while the prime indices of n are row n of A112798. - Gus Wiseman, Nov 30 2019

Examples

			From _Gus Wiseman_, Nov 30 2019: (Start)
The sequence of squarefree numbers together with their prime indices (A329631) and the number a(n) with those binary indices begins:
   1 ->  {}      ->   0
   2 ->  {1}     ->   1
   3 ->  {2}     ->   2
   5 ->  {3}     ->   4
   6 ->  {1,2}   ->   3
   7 ->  {4}     ->   8
  10 ->  {1,3}   ->   5
  11 ->  {5}     ->  16
  13 ->  {6}     ->  32
  14 ->  {1,4}   ->   9
  15 ->  {2,3}   ->   6
  17 ->  {7}     ->  64
  19 ->  {8}     -> 128
  21 ->  {2,4}   ->  10
  22 ->  {1,5}   ->  17
  23 ->  {9}     -> 256
  26 ->  {1,6}   ->  33
  29 ->  {10}    -> 512
  30 ->  {1,2,3} ->   7
(End)
		

Crossrefs

Inverse: A246353 (see also A064273).
Cf. A019565.
A similar encoding of set-systems is A329661.
Cf. A087207.

Programs

  • Maple
    encode_sqrfrees := proc(upto_n) local b,i; b := [ ]; for i from 1 to upto_n do if(0 <> mobius(i)) then b := [ op(b), bef(i) ]; fi; od: RETURN(b); end; # see A048623 for bef
  • Mathematica
    Join[{0}, Total[2^(PrimePi[FactorInteger[#][[All, 1]]] - 1)]& /@ Select[ Range[2, 100], SquareFreeQ]] (* Jean-François Alcover, Mar 15 2016 *)
  • PARI
    lista(nn) = {for (n=1, nn, if (issquarefree(n), if (n==1, x = 0, f = factor(n); x = sum(k=1, #f~, 2^(primepi(f[k, 1])-1))); print1(x, ", "); ); ); } \\ Michel Marcus, Oct 02 2015
    
  • Python
    from math import isqrt
    from sympy import mobius, primepi, primefactors
    def A048672(n):
        if n == 1: return 0
        def f(x): return int(n-sum(mobius(k)*(x//k**2) for k in range(2, isqrt(x)+1)))
        m, k = n, f(n)
        while m != k: m, k = k, f(k)
        return sum(1<Chai Wah Wu, Feb 22 2025

Formula

a(n) = 2^(i1-1)+2^(i2-1)+...+2^(iz-1), where A005117(n) = p_i1*p_i2*p_i3*...*p_iz.
A019565(a(n)) = A005117(n). - Peter Munn, Nov 19 2019
A000120(a(n)) = A072047(n). - Gus Wiseman, Nov 30 2019
a(n) = A087207(A005117(n)). - Flávio V. Fernandes, Feb 26 2025

A048623 Binary encoding of semiprimes (A001358).

Original entry on oeis.org

2, 3, 4, 5, 9, 6, 10, 17, 8, 33, 18, 65, 12, 129, 34, 257, 16, 66, 20, 130, 513, 1025, 36, 258, 2049, 24, 4097, 68, 8193, 514, 40, 1026, 16385, 132, 32769, 2050, 260, 65537, 72, 32, 131073, 4098, 8194, 136, 262145, 16386, 524289, 48, 516, 1048577, 1028
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

Permutation of A048645 (without the term 1).

Examples

			Squares p_i^2 are encoded with a single bit in position i (e.g. 25=ithprime(3)*ithprime(3) => 2^3 = 8) and other terms p_i*p_j are encoded with two bits, as sum 2^(i-1)+2^(j-1)
		

Crossrefs

Programs

  • Maple
    nthprime := proc(n) local i; if(isprime(n)) then for i from 1 to 1000000 do if(ithprime(i) = n) then RETURN(i); fi; od; else RETURN(0); fi; end; # nthprime(2) = 1, nthprime(3) = 2, nthprime(5) = 3, etc.
    bef := proc(n) local s,d; s := 0; for d in ifactors(n)[ 2 ] do s := s + d[ 2 ]*(2^(nthprime(d[ 1 ])-1)); od; RETURN(s); end; # bef = Binary Encode Factorization.
    encode_semiprimes := proc(upto_n) local b,i; b := [ ]; for i from 1 to upto_n do if((3 = tau(i)) or ((0 <> mobius(i)) and (4 = tau(i)))) then b := [ op(b), bef(i) ]; fi; od: RETURN(b); end;
  • Mathematica
    f[n_] := Block[{p = FactorInteger@ n}, Total[2^PrimePi@ # &@ Map[First, p - If[Length@ p == 2, 1, 0]]]]; f /@ Select[Range@ 156, PrimeOmega@ # == 2 &] (* Michael De Vlieger, Oct 01 2015 *)
  • PARI
    lista(nn) = {for (n=1, nn, if (bigomega(n)==2, if (issquare(n), x = 2^primepi(sqrtint(n)), f = factor(n); x = sum(k=1, #f~, 2^(primepi(f[k,1]) - 1))); print1(x, ", ");););} \\ Michel Marcus, Oct 02 2015
    
  • Python
    from math import isqrt
    from sympy import primepi, primerange, factorint
    def A048623(n):
        def f(x): return int(n+x+((t:=primepi(s:=isqrt(x)))*(t-1)>>1)-sum(primepi(x//p) for p in primerange(s+1)))
        m, k = n, f(n)
        while m != k: m, k = k, f(k)
        return sum(e<Chai Wah Wu, Feb 22 2025

A048640 Binary encoding of the squarefree numbers, A005117.

Original entry on oeis.org

1, 2, 4, 8, 6, 16, 10, 32, 64, 18, 12, 128, 256, 20, 34, 512, 66, 1024, 14, 2048, 36, 130, 24, 4096, 258, 68, 8192, 22, 16384, 514, 32768, 132, 65536, 40, 260, 1026, 131072, 262144, 2050, 72, 38, 524288, 516, 26, 1048576, 2097152, 4098, 48, 70, 4194304
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Examples

			10 = 2*5 = p_1*p_3 -> 2^1+2^3 = 2+8 = 10.
		

Crossrefs

Cf. A048639.

Programs

  • Mathematica
    Total[2^PrimePi@ # &@ Map[First, FactorInteger@ #]] & /@ Select[Range@ 80, SquareFreeQ] (* Michael De Vlieger, Oct 01 2015 *)
  • PARI
    lista(nn) = {for (n=1, nn, if (issquarefree(n), if (n==1, x = n, f = factor(n); x = sum(k=1, #f~, 2^primepi(f[k,1]))); print1(x, ", ");););} \\ Michel Marcus, Oct 01 2015
    
  • Python
    from math import isqrt
    from sympy import mobius, primepi, primefactors
    def A048640(n):
        if n == 1: return 1
        def f(x): return int(n-sum(mobius(k)*(x//k**2) for k in range(2, isqrt(x)+1)))
        m, k = n, f(n)
        while m != k: m, k = k, f(k)
        return sum(1<Chai Wah Wu, Dec 23 2024

Formula

a(n) = 2^i1+2^i2+...+2^iz, where A005117(n) = p_i1*p_i2*p_i3*...*p_iz (p_i stands for the i-th prime, where the first prime is 2).

A048676 Binary encoding of factorizations, alternative 2, a(n) = bef2(n);.

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 8, 4, 4, 5, 16, 4, 32, 9, 6, 8, 64, 5, 128, 6, 10, 17, 256, 6, 8, 33, 8, 10, 512, 7, 1024, 16, 18, 65, 12, 6, 2048, 129, 34, 8, 4096, 11, 8192, 18, 8, 257, 16384, 10, 16, 9, 66, 34, 32768, 9, 20, 12, 130, 513, 65536, 8, 131072, 1025, 12, 32, 36, 19
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

Gives same values as A048675 if the source sequence is squarefree (A048672), or there are max two prime divisors or one p with max exponent being 2 (A048623 and A048639).

Crossrefs

Cf. A048675.

Programs

  • Maple
    bef2 := proc(n) local s,d; s := 0; for d in ifactors(n)[ 2 ] do s := s + (2^(nthprime(d[ 1 ])+d[ 2 ]-2)); od; RETURN(s); end; # for nthprime see A048675
  • PARI
    a(n) = {if (n==1, return (0)); my(f = factor(n)); sum(k=1, #f~, 2^(primepi(f[k, 1])+f[k, 2]))/4;} \\ Michel Marcus, Oct 02 2015

Formula

a(1) = 0, a(n) = 1/4 * (2^(i1+e1) + 2^(i2+e2) + ... + 2^(iz+ez)) if n = p_i1^e1*p_i2^e2*...*p_iz^ez, where p_i is i-th prime. (e.g. p1=2, p2=3).
Showing 1-7 of 7 results.