login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 9

%I #17 Mar 15 2024 03:55:59

%S 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 61,23,35,25,37,27,39,63,42,66,45,69,48,72,51,33,53,79,56,36,58,38,60,

%U 40,62,94,12,96,124,44,70,46,131,49,73,113,76,52,78,54,80,192,84,126,87

%N 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 Robert Israel, <a href="/A099506/b099506.txt">Table of n, a(n) for n = 1..10000</a>

%e a(1)=1 by definition.

%e 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 Likewise, a(3)=6 so that a(3)+a(2)=6+3=9 which is a multiple of 3.

%e a(4)=2 so that a(4)+a(3)=2+6=8 and so on.

%o (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 (MATLAB)

%o N = 100;

%o M = 10*N; % find a(1) to a(N) or until a(n) > M

%o B = zeros(1,M);

%o A = zeros(1,N);

%o mmin = 2;

%o A(1) = 1;

%o B(1) = 1;

%o for n = 2:N

%o for m = mmin:M

%o if mmin == m && B(m) == 1

%o mmin = mmin+1;

%o elseif B(m) == 0 && rem(m + A(n-1),n) == 0

%o A(n) = m;

%o B(m) = 1;

%o if m == mmin

%o mmin = mmin + 1;

%o end;

%o break

%o end;

%o end;

%o if A(n) == 0

%o break

%o end

%o end;

%o if A(n) == 0

%o A(1:n-1)

%o else

%o A

%o end; % _Robert Israel_, Jun 17 2015

%Y Cf. A099507 for positions of occurrences of integers in this sequence.

%Y Cf. A125717.

%K easy,nonn

%O 1,2

%A Mark Hudson (mrmarkhudson(AT)hotmail.com), Oct 20 2004

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 18:05 EDT 2024. Contains 371798 sequences. (Running on oeis4.)