Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace nth_digit
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- int index = int.Parse(Console.ReadLine());
- Console.WriteLine(FindNthDigit(number, index));
- }
- static int FindNthDigit(int number, int index)
- {
- int currentIndex = 0;
- int currentNumber = 0;
- while (number > 0)
- {
- currentIndex++;
- if (currentIndex == index)
- {
- currentNumber = number % 10;
- }
- else
- {
- number = number / 10;
- }
- }
- return currentNumber;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement