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

A010051 Characteristic function of primes: 1 if n is prime, else 0.

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0
Offset: 1

Views

Author

Keywords

Comments

The following sequences all have the same parity (with an extra zero term at the start of a(n)): a(n), A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
Hardy and Wright prove that the real number 0.011010100010... is irrational. See Nasehpour link. - Michel Marcus, Jun 21 2018
The spectral components (excluding the zero frequency) of the Fourier transform of the partial sequences {a(j)} with j=1..n and n an even number, exhibit a remarkable symmetry with respect to the central frequency component at position 1 + n/4. See the Fourier spectrum of the first 2^20 terms in Links, Comments in A289777, and Conjectures in A001223 of Sep 01 2019. It also appears that the symmetry grows with n. - Andres Cicuttin, Aug 23 2020

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 3.
  • V. Brun, Über das Goldbachsche Gesetz und die Anzahl der Primzahlpaare, Arch. Mat. Natur. B, 34, no. 8, 1915.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, Oxford University Press, London, 1975.
  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 65.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See p. 132.

Crossrefs

Cf. A051006 (constant 0.4146825... (base 10) = 0.01101010001010001010... (base 2)), A001221 (inverse Moebius transform), A143519, A156660, A156659, A156657, A059500, A053176, A059456, A072762.
First differences of A000720, so A000720 gives partial sums.
Column k=1 of A117278.
Characteristic function of A000040.
Cf. A008683.

Programs

  • Haskell
    import Data.List (unfoldr)
    a010051 :: Integer -> Int
    a010051 n = a010051_list !! (fromInteger n-1)
    a010051_list = unfoldr ch (1, a000040_list) where
       ch (i, ps'@(p:ps)) = Just (fromEnum (i == p),
                                  (i + 1, if i == p then ps else ps'))
    -- Reinhard Zumkeller, Apr 17 2012, Sep 15 2011
    
  • Magma
    s:=[]; for n in [1..100] do if IsPrime(n) then s:=Append(s,1); else s:=Append(s,0); end if; end for; s;
    
  • Magma
    [IsPrime(n) select 1 else 0: n in [1..100]];  // Bruno Berselli, Mar 02 2011
    
  • Maple
    A010051:= n -> if isprime(n) then 1 else 0 fi;
  • Mathematica
    Table[ If[ PrimeQ[n], 1, 0], {n, 105}] (* Robert G. Wilson v, Jan 15 2005 *)
    Table[Boole[PrimeQ[n]], {n, 105}] (* Alonso del Arte, Aug 09 2011 *)
    Table[PrimePi[n] - PrimePi[n-1], {n,50}] (* G. C. Greubel, Jan 05 2017 *)
  • PARI
    a(n)=isprime(n) \\ Charles R Greathouse IV, Apr 16 2011
    
  • Python
    from sympy import isprime
    def A010051(n): return int(isprime(n)) # Chai Wah Wu, Jan 20 2022

Formula

a(n) = floor(cos(Pi*((n-1)! + 1)/n)^2) for n >= 2. - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Nov 07 2002
Let M(n) be the n X n matrix m(i, j) = 0 if n divides ij + 1, m(i, j) = 1 otherwise; then for n > 0 a(n) = -det(M(n)). - Benoit Cloitre, Jan 17 2003
n >= 2, a(n) = floor(phi(n)/(n - 1)) = floor(A000010(n)/(n - 1)). - Benoit Cloitre, Apr 11 2003
a(n) = Sum_{d|gcd(n, A034386(n))} mu(d). [Brun]
a(m*n) = a(m)*0^(n - 1) + a(n)*0^(m - 1). - Reinhard Zumkeller, Nov 25 2004
a(n) = 1 if n has no divisors other than 1 and n, and 0 otherwise. - Jon Perry, Jul 02 2005
Dirichlet generating function: Sum_{n >= 1} a(n)/n^s = primezeta(s), where primezeta is the prime zeta function. - Franklin T. Adams-Watters, Sep 11 2005
a(n) = (n-1)!^2 mod n. - Franz Vrabec, Jun 24 2006
a(n) = A047886(n, 1). - Reinhard Zumkeller, Apr 15 2008
Equals A051731 (the inverse Möbius transform) * A143519. - Gary W. Adamson, Aug 22 2008
a(n) = A051731((n + 1)! + 1, n) from Wilson's theorem: n is prime if and only if (n + 1)! is congruent to -1 mod n. - N-E. Fahssi, Jan 20 2009, Jan 29 2009
a(n) = A166260/A001477. - Mats Granvik, Oct 10 2009
a(n) = 0^A070824, where 0^0=1. - Mats Granvik, Gary W. Adamson, Feb 21 2010
It appears that a(n) = (H(n)*H(n + 1)) mod n, where H(n) = n!*Sum_{k=1..n} 1/k = A000254(n). - Gary Detlefs, Sep 12 2010
Dirichlet generating function: log( Sum_{n >= 1} 1/(A112624(n)*n^s) ). - Mats Granvik, Apr 13 2011
a(n) = A100995(n) - sqrt(A100995(n)*A193056(n)). - Mats Granvik, Jul 15 2011
a(n) * (2 - n mod 4) = A151763(n). - Reinhard Zumkeller, Oct 06 2011
(n - 1)*a(n) = ( (2*n + 1)!! * Sum_{k=1..n}(1/(2*k + 1))) mod n, n > 2. - Gary Detlefs, Oct 07 2011
For n > 1, a(n) = floor(1/A001222(n)). - Enrique Pérez Herrero, Feb 23 2012
a(n) = mu(n) * Sum_{d|n} mu(d)*omega(d), where mu is A008683 and omega A001222 or A001221 indistinctly. - Enrique Pérez Herrero, Jun 06 2012
a(n) = A003418(n+1)/A003418(n) - A217863(n+1)/A217863(n) = A014963(n) - A072211(n). - Eric Desbiaux, Nov 25 2012
For n > 1, a(n) = floor(A014963(n)/n). - Eric Desbiaux, Jan 08 2013
a(n) = ((abs(n-2))! mod n) mod 2. - Timothy Hopper, May 25 2015
a(n) = abs(F(n)) - abs(F(n)-1/2) - abs(F(n)-1) + abs(f(n)-3/2), where F(n) = Sum_{m=2..n+1} (abs(1 - (n mod m)) - abs(1/2 - (n mod m)) + 1/2), n > 0. F(n) = 1 if n is prime, > 1 otherwise, except F(1) = 0. a(n) = 1 if F(n) = 1, 0 otherwise. - Timothy Hopper, Jun 16 2015
For n > 4, a(n) = (n-2)! mod n. - Thomas Ordowski, Jul 24 2016
From Ilya Gutkovskiy, Jul 24 2016: (Start)
G.f.: A(x) = Sum_{n>=1} x^A000040(n) = B(x)*(1 - x), where B(x) is the g.f. for A000720.
a(n) = floor(2/A000005(n)), for n>1. (End)
a(n) = pi(n) - pi(n-1) = A000720(n) - A000720(n-1), for n>=1. - G. C. Greubel, Jan 05 2017
Decimal expansion of Sum_{k>=1} (1/10)^prime(k) = 9 * Sum_{k>=1} pi(k)/10^(k+1), where pi(k) = A000720(k). - Amiram Eldar, Aug 11 2020
a(n) = 1 - ceiling((2/n) * Sum_{k=2..floor(sqrt(n))} floor(n/k)-floor((n-1)/k)), n>1. - Gary Detlefs, Sep 08 2023
a(n) = Sum_{d|n} mu(d)*omega(n/d), where mu = A008683 and omega = A001221. - Ridouane Oudra, Apr 12 2025
a(n) = 0 if (n^2 - 3*n + 2) * A000203(n) - 8 * A002127(n) > 0 else 1 (n>2, see Craig link). - Bill McEachen, Jul 04 2025

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

A135141 a(1)=1, a(p_n)=2*a(n), a(c_n)=2*a(n)+1, where p_n = n-th prime, c_n = n-th composite number.

Original entry on oeis.org

1, 2, 4, 3, 8, 5, 6, 9, 7, 17, 16, 11, 10, 13, 19, 15, 12, 35, 18, 33, 23, 21, 14, 27, 39, 31, 25, 71, 34, 37, 32, 67, 47, 43, 29, 55, 22, 79, 63, 51, 20, 143, 26, 69, 75, 65, 38, 135, 95, 87, 59, 111, 30, 45, 159, 127, 103, 41, 24, 287, 70, 53, 139, 151, 131, 77, 36, 271, 191
Offset: 1

Views

Author

Katarzyna Matylla, Feb 13 2008

Keywords

Comments

A permutation of the positive integers, related to A078442.
a(p) is even when p is prime and is divisible by 2^(prime order of p).
From Robert G. Wilson v, Feb 16 2008: (Start)
What is the length of the cycle containing 10? Is it infinite? The cycle begins 10, 17, 12, 11, 16, 15, 19, 18, 35, 29, 34, 43, 26, 31, 32, 67, 36, 55, 159, 1055, 441, 563, 100, 447, 7935, 274726911, 1013992070762272391167, ... Implementation in Mmca: NestList[a(AT)# &, 10, 26] Furthermore, it appears that any non-single-digit number has an infinite cycle.
Records: 1, 2, 4, 8, 9, 17, 19, 35, 39, 71, 79, 143, 159, 287, 319, 575, 639, 1151, 1279, 2303, 2559, 4607, 5119, 9215, 10239, 18431, 20479, 36863, 40959, 73727, 81919, 147455, 163839, 294911, 327679, 589823, 655359, ..., . (End)

Examples

			a(20) = 33 = 2*16 + 1 because 20 is 11th composite and a(11)=16. Or, a(20)=33=100001(bin). In other words it is a composite number, its index is a prime number, whose index is a prime....
		

Crossrefs

Cf. A246346, A246347 (record positions and values).
Cf. A227413 (inverse).
Cf. A071574, A245701, A245702, A245703, A245704, A246377, A236854, A237427 for related and similar permutations.

Programs

  • Haskell
    import Data.List (genericIndex)
    a135141 n = genericIndex a135141_list (n-1)
    a135141_list = 1 : map f [2..] where
       f x | iprime == 0 = 2 * (a135141 $ a066246 x) + 1
           | otherwise   = 2 * (a135141 iprime)
           where iprime = a049084 x
    -- Reinhard Zumkeller, Jan 29 2014
    
  • Mathematica
    a[1] = 1; a[n_] := If[PrimeQ@n, 2*a[PrimePi[n]], 2*a[n - 1 - PrimePi@n] + 1]; Array[a, 69] (* Robert G. Wilson v, Feb 16 2008 *)
  • Maxima
    /* Let pc = prime count (which prime it is), cc = composite count: */
    pc[1]:0;
    cc[1]:0;
    pc[2]:1;
    cc[4]:1;
    pc[n]:=if primep(n) then 1+pc[prev_prime(n)] else 0;
    cc[n]:=if primep(n) then 0 else if primep(n-1) then 1+cc[n-2] else 1+cc[n-1];
    a[1]:1;
    a[n]:=if primep(n) then 2*a[pc[n]] else 1+2*a[cc[n]];
    
  • PARI
    A135141(n) = if(1==n, 1, if(isprime(n), 2*A135141(primepi(n)), 1+(2*A135141(n-primepi(n)-1)))); \\ Antti Karttunen, Dec 09 2019
  • Python
    from sympy import isprime, primepi
    def a(n): return 1 if n==1 else 2*a(primepi(n)) if isprime(n) else 2*a(n - 1 - primepi(n)) + 1 # Indranil Ghosh, Jun 11 2017, after Mathematica code
    

Formula

a(n) = 2*A135141((A049084(n))*chip + A066246(n)*(1-chip)) + 1 - chip, where chip = A010051(n). - Reinhard Zumkeller, Jan 29 2014
From Antti Karttunen, Dec 09 2019: (Start)
A007814(a(n)) = A078442(n).
A070939(a(n)) = A246348(n).
A080791(a(n)) = A246370(n).
A054429(a(n)) = A246377(n).
A245702(a(n)) = A245703(n).
a(A245704(n)) = A245701(n). (End)

A035026 Number of times that i and 2n-i are both prime, for i = 1, ..., 2n-1.

Original entry on oeis.org

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

Views

Author

Gordon R. Bower (siegmund(AT)mosquitonet.com)

Keywords

Comments

a(n) is the convolution of terms 1 to 2n of the characteristic function of the primes, A010051, with itself. Related to Goldbach's conjecture that every even number can be expressed as the sum of two primes. - T. D. Noe, Aug 01 2002
The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
Total number of printer jobs in all possible schedules for n time slots in the first-come-first-served (FCFS) policy.
a(n) = Sum_{p prime < 2*n} A010051(2*n - p). - Reinhard Zumkeller, Oct 19 2011
For n > 1: length of n-th row of triangle A171637. - Reinhard Zumkeller, Mar 03 2014
a(n) = A001221(A238711(n)) = A238778(n) / n. - Reinhard Zumkeller, Mar 06 2014
From Robert G. Wilson v, Dec 15 2016: (Start)
First occurrence of k: 1, 2, 4, 5, 8, 11, 12, 17, 18, 37, 24, 53, 30, 89, 39, 71, 42, 101, 45, 179, 57, 137, 72, 193, 60, 233, ..., .
Conjectured last occurrence of k: 1, 3, 6, 19, 34, 31, 64, 61, 76, 79, 94, 83, 166, 199, 136, 181, 184, 229, 244, 271, 316, 277, 346, 313, 301, 293, ..., .
Conjectured number occurrences of k: 1, 2, 2, 3, 6, 3, 8, 4, 7, 5, 11, 5, 11, 8, 10, 3, 17, 7, 16, 3, 13, 8, 21, 4, 12, 3, 22, 7, 20, 8, 15, ..., .
Records: 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 26, 28, 38, 42, 48, 54, 60, 64, 82, 88, 102, 104, 114, 116, 136, 146, 152, 166, 182, ..., .
(End)

Crossrefs

Cf. A010051. Essentially the same as A002372.
Cf. A073610.

Programs

  • Haskell
    a035026 n = sum $ map (a010051 . (2 * n -)) $
       takeWhile (< 2 * n) a000040_list
    -- Reinhard Zumkeller, Oct 19 2011
  • Maple
    A035026 := proc(n)
        local a,i ;
        a := 0 ;
        for i from 1 to 2*n-1 do
            if isprime(i) and isprime(2*n-i) then
                a := a+1 ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Jul 01 2013
  • Mathematica
    For[lst={}; n=1, n<=100, n++, For[cnt=0; i=1, i<=2n-1, i++ If[PrimeQ[i]&&PrimeQ[2n-i], cnt++ ]]; AppendTo[lst, cnt]]; lst
    f[n_] := Block[{c = Boole@ PrimeQ[ n/2], p = 2}, While[ 2p < n, If[ PrimeQ[n - p], c += 2]; p = NextPrime@ p]; c];; Array[ f[ 2#] &, 90] (* Robert G. Wilson v, Dec 15 2016 *)

Formula

For n > 1, a(n) = 2*A045917(n) - A010051(n).
a(n) = A010051(n) + 2*A061357(n). - Wesley Ivan Hurt, Aug 21 2013
a(n) = A073610(2*n). - Ridouane Oudra, Sep 06 2023

Extensions

Corrected by T. D. Noe, May 05 2002

A061007 a(n) = -(n-1)! mod n.

Original entry on oeis.org

0, 1, 1, 2, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0
Offset: 1

Views

Author

Henry Bottomley, Apr 12 2001

Keywords

Comments

The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
In particular, this is identical to the isprime function A010051 except for a(4) = 2 instead of 0. This is equivalent to Wilson's theorem, (n-1)! == -1 (mod n) iff n is prime. If n = p*q with p, q > 1, then p, q < n-1 and (n-1)! will contain the two factors p and q, unless p = q = 2 (if p = q > 2 then also 2p < n-1, so there are indeed two factors p in (n-1)!), whence (n-1)! == 0 (mod n). - M. F. Hasler, Jul 19 2024

Examples

			a(4) = 2 since -(4 - 1)! = -6 = 2 mod 4.
a(5) = 1 since -(5 - 1)! = -24 = 1 mod 5.
a(6) = 0 since -(6 - 1)! = -120 = 0 mod 6.
		

Crossrefs

Positive for all but the first term of A046022.
Cf. A000040 (the primes), A000142, A010051 (isprime function), A055976, A061006, A061008, A061009.

Programs

Formula

a(4) = 2, a(p) = 1 for p prime, a(n) = 0 otherwise. Apart from n = 4, a(n) = A010051(n) = A061006(n)/(n-1).

A069754 Counts transitions between prime and nonprime to reach the number n.

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 14, 14, 15, 16, 16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20, 20, 21, 22, 22, 22, 23, 24, 25, 26, 26, 26, 27, 28, 28, 28, 28, 28, 29, 30, 30, 30, 30, 30, 31, 32, 33, 34, 34, 34, 34, 34, 35, 36, 36, 36, 37, 38, 39
Offset: 1

Views

Author

T. D. Noe, May 02 2002

Keywords

Comments

The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002

Examples

			a(6) = 4 because there are 4 transitions: 1 to 2, 3 to 4, 4 to 5 and 5 to 6.
		

Crossrefs

Cf. A000720 (pi).
Cf. A211005 (run lengths).
Same parity: A010051, A061007, A035026, A071574.

Programs

  • Haskell
    a069754 1 = 0
    a069754 2 = 1
    a069754 n = 2 * a000720 n - 2 - (toInteger $ a010051 $ toInteger n)
    -- Reinhard Zumkeller, Dec 04 2012
  • Mathematica
    For[lst={0}; trans=0; n=2, n<100, n++, If[PrimeQ[n]!=PrimeQ[n-1], trans++ ]; AppendTo[lst, trans]]; lst
    (* Second program: *)
    pts[n_]:=Module[{c=2PrimePi[n]},If[PrimeQ[n],c-3,c-2]]; Join[{0,1},Array[ pts,80,3]] (* Harvey P. Dale, Nov 12 2011 *)
    Accumulate[If[Sort[PrimeQ[#]]=={False,True},1,0]&/@Partition[ Range[ 0,80],2,1]] (* Harvey P. Dale, May 06 2013 *)

Formula

When n is prime, a(n) = 2*pi(n) - 3. When n is composite, a(n) = 2*pi(n) - 2. pi(n) is the prime counting function A000720.
For n > 2: a(n) = 2*A000720(n) - 2 - A010051(n). - Reinhard Zumkeller, Dec 04 2012

A237739 a(0) = 1, a(2n) = nthcomposite(a(n)-1), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040.

Original entry on oeis.org

1, 2, 4, 3, 8, 7, 6, 5, 14, 19, 12, 17, 10, 13, 9, 11, 22, 43, 28, 67, 20, 37, 26, 59, 16, 29, 21, 41, 15, 23, 18, 31, 33, 79, 60, 191, 40, 107, 91, 331, 30, 71, 52, 157, 38, 101, 81, 277, 25, 53, 42, 109, 32, 73, 57, 179, 24, 47, 34, 83, 27, 61, 45, 127, 48
Offset: 0

Views

Author

Reinhard Zumkeller, Apr 30 2014

Keywords

Comments

A071574(a(n)) = n; a(A071574(n)) = n for n > 0.

Crossrefs

Inverse: A071574.
Compare also to the permutation A246378.

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a237739 = fromIntegral . (+ 1) . fromJust . (`elemIndex` a071574_list)
    
  • PARI
    default(primelimit,(2^31)+(2^30));
    A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n }; \\ This function from M. F. Hasler
    A237739(n) = if(0==n, 1, if(!(n%2), A002808(A237739(n/2)-1), prime(A237739((n-1)/2))));
    for(n=0, 4095, write("b237739.txt", n, " ", A237739(n)));
    \\ Antti Karttunen, Apr 04 2015
    
  • Scheme
    ;; With memoizing definec-macro.
    (definec (A237739 n) (cond ((zero? n) 1) ((odd? n) (A000040 (A237739 (/ (- n 1) 2)))) (else (A002808 (+ -1 (A237739 (/ n 2)))))))
    ;; Antti Karttunen, Apr 04 2015

Formula

a(0) = 1, a(2n) = nthcomposite(a(n)-1), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040. - Antti Karttunen, Apr 04 2015

Extensions

Name replaced by an explicit recurrence. - Antti Karttunen, Apr 04 2015

A269847 Permutation of natural numbers: a(1) = 1, for n > 1, if n is an odd prime, a(n) = A003961(a(A000720(n))), otherwise a(n) = 2*a(n-A000720(n)).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 8, 10, 12, 7, 18, 15, 16, 20, 24, 25, 14, 27, 36, 30, 32, 21, 40, 48, 50, 28, 54, 45, 72, 11, 60, 64, 42, 80, 96, 75, 100, 56, 108, 35, 90, 81, 144, 22, 120, 63, 128, 84, 160, 192, 150, 135, 200, 112, 216, 70, 180, 49, 162, 33, 288, 44, 240, 126, 256, 125, 168, 320, 384, 225, 300, 105, 270, 400
Offset: 1

Views

Author

Antti Karttunen, Mar 06 2016

Keywords

Crossrefs

Inverse: A269848.
Related or similar permutations: A071574, A163511, A246681, A257730, A269857.

Formula

a(1) = 1, and for n > 1, if n is an odd prime, a(n) = A003961(a(A000720(n))), otherwise [when n is 2 or composite] a(n) = 2*a(n-A000720(n)).
a(1) = 1; if n is an odd prime, a(n) = A003961(a(A026233(n))), else a(n) = A005843(a(A026233(n))).
Declarative definition:
a(1)=1, a(A065091(n)) = A003961(a(n+1)), a(A065090(n+1)) = 2*a(n).
As a composition of other permutations:
a(n) = A163511(A071574(n)).
Other identities. For all n >= 1:
a(A007097(n)) = A000040(n). [Maps the terms of primeth recurrence to primes.]

A269857 Permutation of natural numbers: a(1) = 1; if n is an odd prime, a(n) = A250469(a(A026233(n))), else a(n) = 2*(a(A026233(n))).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 8, 10, 12, 7, 18, 15, 16, 20, 24, 25, 14, 21, 36, 30, 32, 27, 40, 48, 50, 28, 42, 33, 72, 11, 60, 64, 54, 80, 96, 51, 100, 56, 84, 35, 66, 45, 144, 22, 120, 57, 128, 108, 160, 192, 102, 69, 200, 112, 168, 70, 132, 49, 90, 39, 288, 44, 240, 114, 256, 55, 216, 320, 384, 105, 204, 87, 138, 400
Offset: 1

Views

Author

Antti Karttunen, Mar 06 2016

Keywords

Crossrefs

Inverse: A269858.
Related or similar permutations: A071574, A252755, A269847.
Differs from A269847 for the first time at n=19, where a(19)=21, while A269847(19)=27.

Formula

a(1) = 1; if n is an odd prime, a(n) = A250469(a(A026233(n))), else a(n) = 2*(a(A026233(n))).
As a composition of other permutations:
a(n) = A252755(A071574(n)).
Showing 1-9 of 9 results.