Given two numbers N and T where, and . The task is to find the value of .
Since sum can be large, output it modulo 109+7.
Input : 3 2 Output : 38 2*3 + 3*4 + 4*5 = 38 Input : 4 2 Output : 68
In the Given Sample Case n = 3 and t = 2.
sum = 2*3+3*4+4*5.
So each term is of the form
If we multiply and divide by t! it becomes
Which is nothing but
But we know
So final expression comes out to be
But since n is so large we can not calculate it directly, we have to Simplify the above expression.
On Simplifying we get .
Below is the implementation of above approach
Time Complexity: O(T)
- Find the Number of Maximum Product Quadruples
- Find Nth number of the series 1, 6, 15, 28, 45, .....
- Find the number in a range having maximum product of the digits
- Program to find the Nth number of the series 2, 10, 24, 44, 70.....
- Find number of factors of N when location of its two factors whose product is N is given
- Count number of triplets with product equal to given number with duplicates allowed
- Count number of triplets with product equal to given number with duplicates allowed | Set-2
- Sum and Product of digits in a number that divide the number
- Find two numbers with sum and product both same as N
- Find N integers with given difference between product and sum
- Find if n can be written as product of k numbers
- Find the Product of first N Prime Numbers
- Find four factors of N with maximum product and sum equal to N
- Find four factors of N with maximum product and sum equal to N | Set 3
- Find four factors of N with maximum product and sum equal to N | Set-2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.