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)
- {
- long num = long.Parse(Console.ReadLine());
- int index = int.Parse(Console.ReadLine());
- getIndex(num, index);
- }
- static long getIndex(long num, int index)
- {
- int n = 1;
- while (num > 0)
- {
- var current = num % 10;
- if (n == index)
- {
- Console.WriteLine(current);
- }
- else
- {
- num = num / 10;
- }
- n++;
- }
- return num;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment