Skip to content

Latest commit

 

History

History

144-digit-statistics

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Digit statistics

Challenge Description:

Given the numbers "a" and "n" find out how many times each digit from zero to nine is the last digit of the number in a sequence [ a, a2, a3, ... an-1, an ]

Input sample:

Your program should accept as its first argument a path to a filename. Each line of input contains two space separated integers "a" and "n" E.g:

2 5

Output sample:

For each line of input print out how many times the digits zero, one, two ... nine occur as the last digit of numbers in the sequence E.g:

0: 0, 1: 0, 2: 2, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 1, 9: 0

In this example, the sequence consists of numbers 2, 4, 8, 16 and 32. Among the last digits, the digit two occurs twice, and each of the digits four, six and eight occurs once.

Constraints:
1 ≤ n ≤ 1 000 000 000 000,
2 ≤ a ≤ 9