∩ prime sums ± i

42 views
Skip to first unread message

allie dicelli

unread,
Jan 1, 2026, 2:52:35 PM (7 days ago) Jan 1
to SeqFan
hellos!

below is a small commonlisp generator for three index sequences.


let (s_n) be the sum of the first (n) primes.

* **a**: indices (n) where (s_n + n) is prime
* **b**: indices (n) where (s_n - n) is prime
* **c**: indices where both conditions hold (the intersection)


(defun %generate-sequences (&key (predicate #'cl-primality::primep) (upto 1000))
  "prime indices where the prime sum at index plus-or-minus index is also prime"
  (flet ((make-seq () (make-array 0 :element-type 'integer :fill-pointer 0 :adjustable t)))
    (loop with primes = (loop with primes-array = (make-array 1 :element-type 'integer
                                                             :initial-element 2
                                                             :fill-pointer 1
                                                             :adjustable t)
                              while (< (length primes-array) upto)
                              for i from 3 by 2
                              when (funcall predicate i)
                              do (vector-push-extend i primes-array)
                              finally (return primes-array))
          with seq-a = (make-seq)
          with seq-b = (make-seq)
          with seq-c = (make-seq)
          for prime across primes
          for index from 1
          for sum = prime then (+ sum prime)
          for candidate-a = (funcall predicate (+ sum index))
          for candidate-b = (funcall predicate (- sum index))
          do (when (and candidate-a candidate-b)
               (vector-push-extend index seq-c))
             (when candidate-a
               (vector-push-extend index seq-a))
             (when candidate-b
               (vector-push-extend index seq-b))
          finally (return (list seq-c seq-a seq-b)))))

i suspect **a** and **b** already appear in oeis under other descriptions, but the intersection **c**, as well as the complements and gap structure in (a \cup b), may be of independent interest.

comments welcome; pointers to existing entries appreciated.

best,
zoë trout
librecell

allie dicelli

unread,
Jan 1, 2026, 3:48:03 PM (7 days ago) Jan 1
to seq...@googlegroups.com
addendum: these “sum-prime twins” (sequence c) are the intersection of A046155 and A046156.

zoë trout
librecell

On Jan 1, 2026, at 11:52, allie dicelli <allied...@gmail.com> wrote:

hellos!
--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/ba7c1544-6e67-4499-bec9-cff5605d34ccn%40googlegroups.com.

Hugo Pfoertner

unread,
Jan 4, 2026, 7:09:30 AM (4 days ago) Jan 4
to SeqFan
None of the three index sequences **a**, **b**, **c** currently exist in the database. The reference to A046155 and A046156 must be an error. Neither appears to be related to the described task. I suggest you submit the sequences **a**, ...
Reply all
Reply to author
Forward
0 new messages