cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A234541 Least k such that floor(n/k) + (n mod k) is a prime, or 0 if no such k exists.

Original entry on oeis.org

0, 1, 1, 2, 1, 2, 1, 4, 2, 2, 1, 4, 1, 2, 3, 8, 1, 6, 1, 4, 2, 2, 1, 8, 2, 2, 5, 4, 1, 6, 1, 6, 2, 2, 3, 12, 1, 2, 3, 8, 1, 6, 1, 4, 2, 2, 1, 16, 3, 10, 3, 4, 1, 18, 3, 6, 2, 2, 1, 8, 1, 2, 6, 18, 3, 6, 1, 4, 3, 4, 1, 14, 1, 2, 9, 4, 5, 6, 1, 16, 2, 2, 1, 12, 2, 2
Offset: 1

Views

Author

Alex Ratushnyak, Dec 27 2013

Keywords

Comments

a(n) = 1 only if n is a prime.
a(2m) <= m, because with k=m, floor(2m/m)+(2m mod m) = 2.
a(2m+1) <= 2m: floor((2m+1)/2m) + ((2m+1) mod 2m) = 1 + 1 = 2.

Crossrefs

Programs

  • Python
    primes = [2, 3]
    primFlg = [0]*100000
    primFlg[2] = primFlg[3] = 1
    def appPrime(k):
      for p in primes:
        if k%p==0:  return
        if p*p > k:  break
      primes.append(k)
      primFlg[k] = 1
    for n in range(5, 100000, 6):
      appPrime(n)
      appPrime(n+2)
    for n in range(1, 100000):
      a = 0
      for k in range(1, n):
        c = n//k + n%k
        if primFlg[c]:  # if c in primes:
          a = k
          break
      print(str(a), end=', ')
    
  • Scheme
    ;; MIT/GNU Scheme, with Aubrey Jaffer's SLIB Scheme library and function A234575bi as defined in A234575
    (require 'factor) ;; For predicate prime? from SLIB-library.
    (define (A234541 n) (let loop ((k 1)) (cond ((prime? (A234575bi n k)) k) ((> k n) 0) (else (loop (+ 1 k))))))
    ;; Antti Karttunen, Dec 29 2013