OFFSET
2,2
COMMENTS
This sequence aims to "encode" the result of p mod 4 for p > 2. Note that for p > 2, p mod 4 is in {1, 3}
Start by defining some binary number b. This will be used to store the results of p mod 4 by the following method. For each prime:
Append "1" to b if p mod 4 = 3, or append "0" to b if p mod 4 = 1. b is then converted to base 10, which defines the term in the sequence.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 2..1000
FORMULA
a(n+1) = 2*(a(n)) + floor(prime(n) / 2) mod 2.
EXAMPLE
p p mod 4 b base 10
--------------------------------
3 3 1 1
5 1 10 2
7 3 101 5
11 3 1011 11
13 1 10110 22
17 1 101100 44
19 3 1011001 89
MATHEMATICA
Module[{nn=40, cct}, cct=Table[(Mod[Prime[n], 4]-1)/2, {n, 2, nn}]; Table[FromDigits[Take[cct, k], 2], {k, nn-1}]] (* Harvey P. Dale, Feb 29 2024 *)
PROG
(Python)
from sympy import isprime
binary_string = ""
for i in range(3, 300):
if isprime(i):
num_to_append = str(int(((i % 4)-1)/2))
binary_string += num_to_append
num_in_base_10 = int(binary_string, 2)
print(i, num_to_append, binary_string, num_in_base_10)
(Python)
from sympy import prime
def A362583(n):
c = 0
for i in range(2, n+1):
c = (c<<1)+(prime(i)&3==3)
return c # Chai Wah Wu, Jun 21 2023
(PARI) lista(nn) = my(blist = List(), nlist = List()); forprime (p=3, prime(nn), my(x = ((p % 4) - 1)/2); listput(blist, x); listput(nlist, fromdigits(Vec(blist), 2)); ); Vec(nlist); \\ Michel Marcus, May 02 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Eric Vergo, Apr 30 2023
STATUS
approved