Challenge question - > Changing Numbers
Combinatorics and number theory are very useful in computer science. Solve this problem to improve your skills in these fields. You are given integers and . Let's define . Initially, you have an integer . You can modify it in two ways: Multiply the current number by some number , where is a prime number and . If the current number is divisible by , divide it by , where is a prime number and . Then, we define as the number of distinct numbers you can get if you perform these modifications no more than times in total starting with . You need to find modulo . You are asked to find this sum to avoid printing a lot of numbers. Complete the function distinctNumbers which takes in two integers and and returns a single integer denoting the sum above. Input Format The single line contains two space-separated integers and . Constraints Additionally, for of the total points: . Output Format Print a single number denoting the answer. Sample Input 0 3 1 Sample Output 0 23 Explanation 0 Starting with , you can obtain the following numbers: , , . # Operation Result 0 - 1 1 1*2 2 1 1*3 3 Starting with , you can obtain the following numbers: , , , . # Operation Result 1 2/2 1 0 - 2 1 2*2 4 1 2*3 6 Starting with , you can obtain the following numbers: , , , . # Operation Result 1 3/3 1 0 - 3 1 3*2 6 1 3*3 9 So, , , and you should print . Sample Input 1 4 2 Sample Output 1 82 Default Code: #!/bin/python3 import os import sys # Complete the distinctNumbers function below. def distinctNumbers(n, k): # Return the number of distinct numbers you can get and return the answer modulo 1000000007 if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') nk = input().split() n = int(nk[0]) k = int(nk[1]) result = distinctNumbers(n, k) fptr.write(str(result) + '\n') fptr.close()