A370482 Characteristic function of primes plus characteristic function of even numbers.
1, 0, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1
Offset: 0
Examples
1 is neither prime nor even so a(1) = 0 + 0 = 0. 2 is both a prime and even so a(2) = 1 + 1 = 2. 3 is a prime but odd so a(3) = 1 + 0 = 1. 4 is not a prime but even so a(4) = 0 + 1 = 1.
Links
- Antti Karttunen, Table of n, a(n) for n = 0..100000
Crossrefs
If a(2) were 1 instead of 2, then this would the characteristic function of {0} U A106092, whose complement A014076 gives the positions of 0's. - Antti Karttunen, Jan 17 2025
Programs
-
Mathematica
a[n_] := Boole[PrimeQ[n]] + Boole[EvenQ[n]]; Array[a, 100, 0] (* Amiram Eldar, Mar 31 2024 *)
-
PARI
A370482(n) = (!(n%2) + isprime(n)); \\ Antti Karttunen, Jan 17 2025
-
Python
from sympy import isprime def A370482(n): return isprime(n)+(n&1^1) # Chai Wah Wu, Apr 25 2024
Comments