allie dicelli
unread,Jan 1, 2026, 2:52:35 PM (7 days ago) Jan 1Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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