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
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
LINKS
Moosa Nasir, Example of n = 11323.
EXAMPLE
For n = 11323, start at the most significant digit, which is 1.
On move 1, travel 1 unit right, reaching the second digit 1.
On move 2, travel 1 unit right, reaching the middle digit 3.
On move 3, travel 3 units right (wrapping around), reaching the most significant 1 digit again.
On move 4, travel 1 unit right, reaching the second digit 1 (again).
On move 5, travel 1 unit right, reaching the middle digit 3 (again).
Thus, a(11323) = 3.
PROG
(C++)
int a(int n)
{
int n2 = n;
int size = 0; do { n2 /= 10; size++; } while (n2 != 0);
int * nums = new int[size];
for(int i = size - 1; i >= 0; i--)
{
nums[i] = n % 10;
n /= 10;
}
int currentIndex = 0;
for (int j = 0; j < size; j++)
{
currentIndex += nums[currentIndex];
currentIndex %= size;
}
int returnVal = nums[currentIndex];
delete[] nums;
return returnVal;
}
(Python)
def A358647(n):
s = list(map(int, str(n)))
l, i = len(s), 0
for _ in range(l):
i = (i+s[i])%l
return s[i] # Chai Wah Wu, Nov 30 2022
CROSSREFS
Cf. A357531 (stepping in 1..n).
Sequence in context: A338379 A004426 A262188 * A004430 A285094 A134778
KEYWORD
nonn,base,easy
AUTHOR
Moosa Nasir, Nov 24 2022
STATUS
approved

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 June 30 23:27 EDT 2024. Contains 373911 sequences. (Running on oeis4.)