# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a358647 Showing 1-1 of 1 %I A358647 #24 Nov 30 2022 12:39:40 %S A358647 0,1,2,3,4,5,6,7,8,9,0,1,2,1,4,1,6,1,8,1,2,2,2,2,2,2,2,2,2,2,0,3,2,3, %T A358647 4,3,6,3,8,3,4,4,4,4,4,4,4,4,4,4,0,5,2,5,4,5,6,5,8,5,6,6,6,6,6,6,6,6, %U A358647 6,6,0,7,2,7,4,7,6,7,8,7,8,8,8,8,8,8,8,8,8,8,0,9,2,9,4,9,6,9,8,9 %N A358647 Final digit reached by traveling right (with wraparound) through the digits of n. Each move steps right k places, where k is the digit at the beginning of the move. Moves begin at the most significant digit and d moves are made, where d is the number of digits in n. %H A358647 Moosa Nasir, Example of n = 11323. %e A358647 For n = 11323, start at the most significant digit, which is 1. %e A358647 On move 1, travel 1 unit right, reaching the second digit 1. %e A358647 On move 2, travel 1 unit right, reaching the middle digit 3. %e A358647 On move 3, travel 3 units right (wrapping around), reaching the most significant 1 digit again. %e A358647 On move 4, travel 1 unit right, reaching the second digit 1 (again). %e A358647 On move 5, travel 1 unit right, reaching the middle digit 3 (again). %e A358647 Thus, a(11323) = 3. %o A358647 (C++) %o A358647 int a(int n) %o A358647 { %o A358647 int n2 = n; %o A358647 int size = 0; do { n2 /= 10; size++; } while (n2 != 0); %o A358647 int * nums = new int[size]; %o A358647 for(int i = size - 1; i >= 0; i--) %o A358647 { %o A358647 nums[i] = n % 10; %o A358647 n /= 10; %o A358647 } %o A358647 int currentIndex = 0; %o A358647 for (int j = 0; j < size; j++) %o A358647 { %o A358647 currentIndex += nums[currentIndex]; %o A358647 currentIndex %= size; %o A358647 } %o A358647 int returnVal = nums[currentIndex]; %o A358647 delete[] nums; %o A358647 return returnVal; %o A358647 } %o A358647 (Python) %o A358647 def A358647(n): %o A358647 s = list(map(int,str(n))) %o A358647 l, i = len(s), 0 %o A358647 for _ in range(l): %o A358647 i = (i+s[i])%l %o A358647 return s[i] # _Chai Wah Wu_, Nov 30 2022 %Y A358647 Cf. A357531 (stepping in 1..n). %K A358647 nonn,base,easy %O A358647 0,3 %A A358647 _Moosa Nasir_, Nov 24 2022 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE