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 num = int.Parse(Console.ReadLine());
- int index = int.Parse(Console.ReadLine());
- int result = FindNthDigit(num, index);
- Console.WriteLine(result);
- }
- static int FindNthDigit(int num, int index)
- {
- int count = 0;
- int digit = 0;
- while (num - 1 != 0)
- {
- digit = num % 10;
- count++;
- if (count == index)
- {
- return digit;
- break;
- }
- num = num / 10;
- }
- return FindNthDigit(num, index);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement