OFFSET
1,1
PROG
(MIT Scheme with MATCHING-POS macro by AK): (define A165607 (MATCHING-POS 1 0 (lambda (n) (let ((w (A004767 n)) (hp (A005408 n))) (let loop ((i 1) (s 1) (zv 0)) (cond ((< s 0) #f) ((>= i hp) (not (zero? zv))) ((zero? s) (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) (1+ zv))) (else (loop (1+ i) (+ s (jacobi-symbol (1+ i) w)) zv))))))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Oct 06 2009
STATUS
approved