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.

A007978 Least non-divisor of n.

This page as a plain text file.
%I A007978 #54 Feb 22 2023 18:12:20
%S A007978 2,3,2,3,2,4,2,3,2,3,2,5,2,3,2,3,2,4,2,3,2,3,2,5,2,3,2,3,2,4,2,3,2,3,
%T A007978 2,5,2,3,2,3,2,4,2,3,2,3,2,5,2,3,2,3,2,4,2,3,2,3,2,7,2,3,2,3,2,4,2,3,
%U A007978 2,3,2,5,2,3,2,3,2,4,2,3,2,3,2,5,2,3,2,3,2,4,2,3,2,3,2,5,2,3,2,3
%N A007978 Least non-divisor of n.
%C A007978 Least k >= 2 such that sigma(n) divides sigma(n*k), where sigma is A000203. - _Benoit Cloitre_, Dec 01 2002
%C A007978 Contains all and only the prime powers p^k, k > 0. The first occurrence of p^k is at A003418(p^k-1); so new records occur at indices in A051451. - _Franklin T. Adams-Watters_, Jun 13 2011
%H A007978 Reinhard Zumkeller, <a href="/A007978/b007978.txt">Table of n, a(n) for n = 1..10000</a>
%H A007978 Bakir Farhi, <a href="https://www.emis.de/journals/INTEGERS/papers/j42/j42.Abstract.html">On the average asymptotic behavior of a certain type of sequences of integers</a>, Integers, Vol. 9 (2009), pp. 555-567.
%F A007978 a(n) = A053669(n) + A061853(n) = A055874(n) + 1. - _Henry Bottomley_, May 10 2001
%F A007978 G.f.: sum(k >= 2, -k*(x^A003418(k) - x^A003418(k-1))/((x^A003418(k) - 1)*(x^A003418(k-1) - 1))). - _Robert Israel_, Sep 02 2014
%F A007978 From _Alonso del Arte_, Sep 23 2017: (Start)
%F A007978 a(n) < n for all n > 2.
%F A007978 a(2n + 1) = 2, a(2n) >= 3.
%F A007978 a(2^k) = 3 for k > 0.
%F A007978 a(n!) = prime(pi(n) + 1) for n >= 0, except for a(3!) = 4. (End)
%F A007978 Asymptotic mean: lim_{n->oo} Sum_{k=1..n} a(k) = 1 + A064859 (Farhi, 2009). - _Amiram Eldar_, Jun 29 2021
%p A007978 a:= proc(n) local k;
%p A007978 for k from 2 while n mod k = 0 do od:
%p A007978 k
%p A007978 end proc:
%p A007978 seq(a(n),n=1..100); # _Robert Israel_, Sep 02 2014
%t A007978 Table[k := 1; While[Mod[n, k] == 0, k++]; k, {n, 2000}]  (* _Clark Kimberling_, Jun 16 2012 *)
%t A007978 Join[{2, 3}, Table[Complement[Range[n], Divisors[n]][[1]], {n, 3, 100}]] (* _Alonso del Arte_, Sep 23 2017 *)
%o A007978 (Haskell)
%o A007978 import Data.List ((\\))
%o A007978 a007978 = head . ([1..] \\) . a027750_row
%o A007978 -- _Reinhard Zumkeller_, May 10 2014
%o A007978 (PARI) a(n) = {my(k=2); while(!(n % k), k++); k;} \\ _Michel Marcus_, Sep 25 2017
%o A007978 (Python)
%o A007978 def a(n):
%o A007978     k = 2
%o A007978     while not n%k: k += 1
%o A007978     return k
%o A007978 print([a(n) for n in range(1, 101)]) # _Michael S. Branicky_, Jul 09 2022
%o A007978 (Python)
%o A007978 def A007978(n): return next(filter(lambda d:n%d,range(2,n))) if n>2 else n+1 # _Chai Wah Wu_, Feb 22 2023
%Y A007978 Cf. A003418, A051451, A055874, A053669, A061853, A027750, A064859.
%Y A007978 Cf. also A266620 (least non-divisor of n!).
%K A007978 nonn
%O A007978 1,1
%A A007978 _Jeffrey Shallit_