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.

A283312 a(n) = smallest missing positive number, unless a(n-1) was a prime in which case a(n) = 2*a(n-1).

This page as a plain text file.
%I A283312 #60 Feb 12 2024 07:37:19
%S A283312 1,2,4,3,6,5,10,7,14,8,9,11,22,12,13,26,15,16,17,34,18,19,38,20,21,23,
%T A283312 46,24,25,27,28,29,58,30,31,62,32,33,35,36,37,74,39,40,41,82,42,43,86,
%U A283312 44,45,47,94,48,49,50,51,52,53,106,54,55,56,57,59,118,60,61,122,63,64,65,66,67,134,68,69
%N A283312 a(n) = smallest missing positive number, unless a(n-1) was a prime in which case a(n) = 2*a(n-1).
%C A283312 Comments from _N. J. A. Sloane_, Nov 02 2020: (Start)
%C A283312 Alternatively, this is the lexicographically earliest infinite sequence of distinct positive numbers such that every prime is followed by its double.
%C A283312 Theorem: This is a permutation of the positive integers.
%C A283312 Proof. Sequence is clearly infinite, so for any k there is a number N_0(k) such that n >= N_0(k) implies a(n) > k.
%C A283312 Suppose m is missing. Consider a(n) for n = N_0(m). Then a(n) must be a prime p (otherwise it would have been m, which is missing), a(n+1) = 2*p, and a(n+2) = m, a contradiction. QED.
%C A283312 (End)
%C A283312 A toy model of A280864, A280985, and A127202.
%C A283312 Alternative definition: a(1,2) = 1,2. Let P(k) = rad(a(1)*a(2)*...*a(k)), then for n > 2, a(n) = P(n)/P(n-1), where rad is A007947. - _David James Sycamore_, Jan 27 2024
%H A283312 N. J. A. Sloane, <a href="/A283312/b283312.txt">Table of n, a(n) for n = 1..75000</a>
%F A283312 There is an explicit formula for the n-th term of the inverse permutation: see A338362.
%F A283312 The graph: Numbers appear in the sequence in their natural order, except when interrupted by the appearance of primes. Suppose a(n)=x, where x is neither a prime nor twice a prime. Then if p is a prime in the range x/2 < p < x, 2p appears in the sequence between p and p+1. Therefore we have the identity
%F A283312 n = x + pi(x) - pi(x/2). ... (1)
%F A283312 If a(n) = x = a prime, then (1) is replaced by
%F A283312 n = x + pi(x) - pi(x/2) - 1. ... (2)
%F A283312 If a(n) = x = twice a prime then
%F A283312 n = x/2 + pi(x/2) - pi(x/4). ... (3)
%F A283312 These equations imply that the lower line in the graph of the sequence is
%F A283312 x approx= n(1 - 1/(2*log n)) ... (4)
%F A283312 while the upper line is
%F A283312 x approx= 2n(1 - 1/(2*log n)). ... (5)
%F A283312 a(2*n-1 + A369610(n)) = prime(n). - _David James Sycamore_, Jan 27 2024
%e A283312 The offset is 1. What is a(1)? It is the smallest missing positive number, which is 1. Similarly, a(2)=2.
%e A283312 What is a(3)? Since the previous term was the prime 2, a(3) = 4.
%e A283312 And so on.
%p A283312 a:=[1];
%p A283312 H:=Array(1..1000,0); MMM:=1000;
%p A283312 H[1]:=1; smn:=2; t:=2;
%p A283312 for n from 2 to 100 do
%p A283312 if t=smn then a:=[op(a),t]; H[t]:=1;
%p A283312    if isprime(t) then a:=[op(a),2*t]; H[2*t]:=1; fi;
%p A283312    t:=t+1;
%p A283312 # update smallest missing number smn
%p A283312    for i from smn+1 to MMM do if H[i]=0 then smn:=i; break; fi; od;
%p A283312 else t:=t+1;
%p A283312 fi;
%p A283312 od:
%p A283312 a;
%t A283312 Module[{nmax = 100, smn = 1}, Nest[Append[#, If[PrimeQ[Last[#]], 2*Last[#], While[MemberQ[#, ++smn]]; smn]]&, {1}, nmax-1]] (* _Paolo Xausa_, Feb 12 2024 *)
%Y A283312 Cf. A127202, A280864, A280985.
%Y A283312 See A283313 for smallest missing number, A338362 for inverse, A338361 for indices of primes, A338357 for first differences.
%Y A283312 For records see A338356 and A001747.
%K A283312 nonn
%O A283312 1,2
%A A283312 _N. J. A. Sloane_, Mar 08 2017
%E A283312 Entry revised by _N. J. A. Sloane_, Nov 03 2020