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.

A099506 a(1)=1; for n > 1, a(n)=smallest m>0 that has not appeared so far in the sequence such that m+a(n-1) is a multiple of n.

This page as a plain text file.
%I A099506 #17 Mar 15 2024 03:55:59
%S A099506 1,3,6,2,8,4,10,14,13,7,15,9,17,11,19,29,5,31,26,34,50,16,30,18,32,20,
%T A099506 61,23,35,25,37,27,39,63,42,66,45,69,48,72,51,33,53,79,56,36,58,38,60,
%U A099506 40,62,94,12,96,124,44,70,46,131,49,73,113,76,52,78,54,80,192,84,126,87
%N A099506 a(1)=1; for n > 1, a(n)=smallest m>0 that has not appeared so far in the sequence such that m+a(n-1) is a multiple of n.
%H A099506 Robert Israel, <a href="/A099506/b099506.txt">Table of n, a(n) for n = 1..10000</a>
%e A099506 a(1)=1 by definition.
%e A099506 a(2)=3 because then a(2)+a(1)=3+1=4 which is a multiple of 2. a(2) cannot be 1 (which would lead to a sum of 2) because this has already appeared.
%e A099506 Likewise, a(3)=6 so that a(3)+a(2)=6+3=9 which is a multiple of 3.
%e A099506 a(4)=2 so that a(4)+a(3)=2+6=8 and so on.
%o A099506 (PARI) v=[1];n=1;while(n<100,s=n+v[#v];if(!(s%(#v+1)||vecsearch(vecsort(v),n)),v=concat(v,n);n=0);n++);v \\ _Derek Orr_, Jun 16 2015
%o A099506 (MATLAB)
%o A099506 N = 100;
%o A099506 M = 10*N;  % find a(1) to a(N) or until a(n) > M
%o A099506 B = zeros(1,M);
%o A099506 A = zeros(1,N);
%o A099506 mmin = 2;
%o A099506 A(1) = 1;
%o A099506 B(1) = 1;
%o A099506 for n = 2:N
%o A099506   for m = mmin:M
%o A099506     if mmin == m && B(m) == 1
%o A099506        mmin = mmin+1;
%o A099506     elseif B(m) == 0 && rem(m + A(n-1),n) == 0
%o A099506       A(n) = m;
%o A099506       B(m) = 1;
%o A099506       if m == mmin
%o A099506          mmin = mmin + 1;
%o A099506       end;
%o A099506       break
%o A099506     end;
%o A099506   end;
%o A099506   if A(n) == 0
%o A099506      break
%o A099506   end
%o A099506 end;
%o A099506 if A(n) == 0
%o A099506   A(1:n-1)
%o A099506 else
%o A099506   A
%o A099506 end; % _Robert Israel_, Jun 17 2015
%Y A099506 Cf. A099507 for positions of occurrences of integers in this sequence.
%Y A099506 Cf. A125717.
%K A099506 easy,nonn
%O A099506 1,2
%A A099506 Mark Hudson (mrmarkhudson(AT)hotmail.com), Oct 20 2004