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!)
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. 2

%I #24 Nov 30 2022 12:39:40

%S 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 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 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 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 Moosa Nasir, <a href="https://raw.githubusercontent.com/TealEgg/MoosaNasir/main/Example11323.png">Example of n = 11323</a>.

%e For n = 11323, start at the most significant digit, which is 1.

%e On move 1, travel 1 unit right, reaching the second digit 1.

%e On move 2, travel 1 unit right, reaching the middle digit 3.

%e On move 3, travel 3 units right (wrapping around), reaching the most significant 1 digit again.

%e On move 4, travel 1 unit right, reaching the second digit 1 (again).

%e On move 5, travel 1 unit right, reaching the middle digit 3 (again).

%e Thus, a(11323) = 3.

%o (C++)

%o int a(int n)

%o {

%o int n2 = n;

%o int size = 0; do { n2 /= 10; size++; } while (n2 != 0);

%o int * nums = new int[size];

%o for(int i = size - 1; i >= 0; i--)

%o {

%o nums[i] = n % 10;

%o n /= 10;

%o }

%o int currentIndex = 0;

%o for (int j = 0; j < size; j++)

%o {

%o currentIndex += nums[currentIndex];

%o currentIndex %= size;

%o }

%o int returnVal = nums[currentIndex];

%o delete[] nums;

%o return returnVal;

%o }

%o (Python)

%o def A358647(n):

%o s = list(map(int,str(n)))

%o l, i = len(s), 0

%o for _ in range(l):

%o i = (i+s[i])%l

%o return s[i] # _Chai Wah Wu_, Nov 30 2022

%Y Cf. A357531 (stepping in 1..n).

%K nonn,base,easy

%O 0,3

%A _Moosa Nasir_, Nov 24 2022

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 July 18 21:02 EDT 2024. Contains 374388 sequences. (Running on oeis4.)