A334067 a(n) is taken to be the smallest positive integer greater than a(n-1) which is consistent with the condition "n is a term of the sequence if and only if a(n) is prime" where indices start from 0.
1, 2, 3, 5, 6, 7, 11, 13, 14, 15, 16, 17, 18, 19, 23, 29, 31, 37, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 59, 60, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 132, 133, 134, 135, 137, 139, 140, 149
Offset: 0
Keywords
Examples
a(0) cannot be 0, since then 0 should be prime, which it is not. a(0) = 1 is valid hence a(1) must be the next prime, which is a(1) = 2. Then a(2) should be the next prime, hence a(2) = 3. a(3) should be prime, hence a(3) = 5. Since 4 is not in the sequence so far, a(4) must be the next nonprime, which means a(4) = 6.
Crossrefs
Programs
-
Python
# is_prime(n) is a Python function which returns True if n is prime, and returns False otherwise. In the form stated below runs with SageMath. def a_list(length): """Returns the list [a(0), ..., a(length-1)].""" num = 1 b = [1] for i in range(1, length): num += 1 if i in b: while not is_prime(num): num += 1 b.append(num) else: while is_prime(num): num += 1 b.append(num) return b print(a_list(63))
Comments