login
Lexicographically earliest sequence where n is banned for n^2 terms after each appearance.
5

%I #33 Jul 31 2023 10:09:41

%S 1,2,1,3,1,4,1,2,1,5,1,6,1,2,1,3,1,7,1,2,1,8,1,4,1,2,1,3,1,9,1,2,1,10,

%T 1,5,1,2,1,3,1,4,1,2,1,11,1,12,1,2,1,3,1,6,1,2,1,13,1,4,1,2,1,3,1,5,1,

%U 2,1,7,1,14,1,2,1,3,1,4,1,2,1,15,1,16,1,2,1,3,1,8,1,2,1,5,1,4

%N Lexicographically earliest sequence where n is banned for n^2 terms after each appearance.

%C After 12427560 terms the sequence is periodic with period 2985984. The largest periodic term is 158.

%C The largest term is 159 which appears only 3 times: a(4942686), a(7756992) and a(9818928).

%C If banning for n terms the sequence just repeats [1,2,1,3] (A364447). If banning for n^3 terms the sequence continues growing forever (A364449).

%C The first 41 terms are shared with A028920.

%H Rok Cestnik, <a href="/A364448/b364448.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = a(n-2985984) for n >= 15413545.

%e a(n) ban 1 2 3 4 5 6 7 ...

%e 1 | | | | | | |

%e 2 x | | | | | |

%e 1 | x | | | | |

%e 3 x x | | | | |

%e 1 | x x | | | |

%e 4 x x x | | | |

%e 1 | | x x | | |

%e 2 x | x x | | |

%e 1 | x x x | | |

%e 5 x x x x | | |

%e 1 | x x x x | |

%e 6 x x x x x | |

%e 1 | | x x x x |

%e 2 x | | x x x |

%e 1 | x | x x x |

%e 3 x x | x x x |

%e 1 | x x x x x |

%e 7 x x x x x x |

%e .

%e .

%e .

%o (Python)

%o a = []

%o ban = [0 for n in range(160)]

%o for i in range(1000):

%o can = ban.index(0,1)

%o ban = [max(b-1,0) for b in ban]

%o a.append(can)

%o ban[can] = can**2

%o (C)

%o #include<stdlib.h>

%o int main(void){

%o int N = 1000;

%o int *a = (int*)malloc((N+1)*sizeof(int));

%o int *ban = (int*)malloc(160*sizeof(int));

%o for(int n = 0; n < N; ++n){

%o for(int can = 1; can < 160; ++can){

%o if(ban[can] == 0){

%o a[n] = can;

%o ban[can] = can*can+1;

%o break;

%o }

%o }

%o for(int can = 1; can < 160; ++can) if(ban[can]) --ban[can];

%o }

%o free(a); free(ban);

%o return 0;

%o }

%Y Cf. A364447, A364449, A028920.

%K nonn,look

%O 1,2

%A _Rok Cestnik_, Jul 25 2023