login
Starting with a(1) = 1, a(n) = smallest nonnegative integer not yet in the sequence such that the last digit of a(n-1) plus the first digit of a(n) is equal to 5. The digit 0 is not allowed.
6

%I #9 Jul 24 2017 12:52:28

%S 1,4,11,41,42,3,2,31,43,21,44,12,32,33,22,34,13,23,24,14,15

%N Starting with a(1) = 1, a(n) = smallest nonnegative integer not yet in the sequence such that the last digit of a(n-1) plus the first digit of a(n) is equal to 5. The digit 0 is not allowed.

%C The number of terms of this finite sequence is the fifth central polygonal number, n = 21.

%t Module[{a = {1}, k}, TimeConstrained[Do[k = 2; While[Or[MemberQ[a, k], MemberQ[IntegerDigits@ k, 0], # != 5] &[Mod[a[[n - 1]], 10] + First@ IntegerDigits@ k], k++]; AppendTo[a, k], {n, 2, 24}], 2]; a] (* _Michael De Vlieger_, Jul 14 2017 *)

%Y Cf. A002061

%K nonn,base,fini,full

%O 1,2

%A _Enrique Navarrete_, Jul 01 2017