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.

A213636 Remainder when n is divided by its least nondivisor.

This page as a plain text file.
%I A213636 #33 Feb 22 2023 18:12:52
%S A213636 1,2,1,1,1,2,1,2,1,1,1,2,1,2,1,1,1,2,1,2,1,1,1,4,1,2,1,1,1,2,1,2,1,1,
%T A213636 1,1,1,2,1,1,1,2,1,2,1,1,1,3,1,2,1,1,1,2,1,2,1,1,1,4,1,2,1,1,1,2,1,2,
%U A213636 1,1,1,2,1,2,1,1,1,2,1,2,1,1,1,4,1,2,1,1,1,2,1,2,1,1,1,1,1,2,1
%N A213636 Remainder when n is divided by its least nondivisor.
%C A213636 Experimentation suggests that every positive integer occurs in this sequence and that
%C A213636 2 occurs only in even numbered positions,
%C A213636 3 occurs in only in positions that are multiples of 12,
%C A213636 4 occurs only in positions that are multiples of 12,
%C A213636 5 occurs only in positions that are multiples of 60,
%C A213636 6 occurs only in positions that are multiples of 60,
%C A213636 7 occurs only in positions that are multiples of 2520, etc.
%C A213636 See A213637 for positions of 1 and A213638 for positions of 2.
%C A213636 From _Robert Israel_, Jul 28 2017: (Start)
%C A213636 Given any positive number m, let q be a prime > m and r = A003418(q-1).  Then a(n) = m if n == m (mod q) and n == 0 (mod r).  By the Chinese Remainder Theorem, such n exists.
%C A213636 On the other hand, if a(n) = m, we must have A007978(n) > m, and then n must be divisible by A003418(q-1) where q = A007978(n) is a member of A000961 greater than m.  Moreover, if q=p^j with j>1, n is divisible by p^(j-1) so m must be divisible by p^(j-1).  Thus:
%C A213636 For m=2, A003418(2)=2.
%C A213636 For m=3, A007978(n) can't be 4 because m is odd, so A007978(n)>= 5 and n must be divisible by A003418(4)=12.
%C A213636 For m=4, A003418(4)=12.
%C A213636 For m=5 or 6, A003418(6)=60.
%C A213636 For m=7, A007978(n) can't be 8 because m is odd, and can't be 9 because m is not divisible by 3, so n must be divisible by A003418(10)=2520. (End)
%H A213636 Antti Karttunen, <a href="/A213636/b213636.txt">Table of n, a(n) for n = 1..10000</a>
%F A213636 a(n) = n - A213635(n).
%F A213636 a(n) = n - m(n)*floor(n/m(n)), where m(n) = A007978(n).
%e A213636 a(10) = 10-3*[10/3] = 1.
%p A213636 f:= proc(n) local k;
%p A213636   for k from 2 do if n mod k <> 0 then return n mod k fi od
%p A213636 end proc:
%p A213636 map(f, [$1..100]); # _Robert Israel_, Jul 27 2017
%t A213636 y=120; z=2000;
%t A213636 t = Table[k := 1; While[Mod[n, k] == 0, k++];
%t A213636    k, {n, 1, z}]  (*A007978*)
%t A213636 Table[Floor[n/t[[n]]], {n, 1, y}] (*A213633*)
%t A213636 Table[n - Floor[n/t[[n]]], {n, 1, y}] (*A213634*)
%t A213636 Table[t[[n]]*Floor[n/t[[n]]], {n, 1, y}] (*A213635*)
%t A213636 t1 = Table[n - t[[n]]*Floor[n/t[[n]]],
%t A213636    {n, 1, z}] (* A213636 *)
%t A213636 Flatten[Position[t1, 1]] (* A213637 *)
%t A213636 Flatten[Position[t1, 2]] (* A213638 *)
%t A213636 rem[n_]:=Module[{lnd=First[Complement[Range[n],Divisors[n]]]},Mod[n,lnd]]; Join[{1,2},Array[rem,100,3]] (* _Harvey P. Dale_, Mar 26 2013 *)
%t A213636 Table[Mod[n, SelectFirst[Range[n + 1], ! Divisible[n, #] &]], {n, 105}] (* _Michael De Vlieger_, Jul 29 2017 *)
%o A213636 (Scheme) (define (A213636 n) (modulo n (A007978 n))) ;; _Antti Karttunen_, Jul 27 2017
%o A213636 (Python)
%o A213636 def a(n):
%o A213636     k=2
%o A213636     while n%k==0: k+=1
%o A213636     return n%k
%o A213636 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jul 28 2017
%o A213636 (Python)
%o A213636 def A213636(n): return next(filter(None, (n%d for d in range(2,n)))) if n>2 else n # _Chai Wah Wu_, Feb 22 2023
%Y A213636 Cf. A000961, A003418, A007978, A213633, A213635, A213637, A213638.
%K A213636 nonn
%O A213636 1,2
%A A213636 _Clark Kimberling_, Jun 16 2012