Problems not solved at the end of Nth day

Given 3 integers K, P and N. Where, K is the number of problems given to the person every day and P is the maximum number of problems he can solve in a day. Find the total number of problems not solved after the N-th day.
Examples: 
 
Input : K = 2, P = 1, N = 3 Output : 3 On each day 1 problem is left so 3*1 = 3 problems left after Nth day. Input : K = 4, P = 1, N = 10 Output : 30
If P is greater than or equal to K then all problems will be solved on that day or (K-P) problems will be solved on each day so the answer will be 0 if K<=P else the answer will be (K-P)*N.
Below is the implementation of the above approach: 
 
C++
| // C++ program to find problems not// solved at the end of Nth day#include <bits/stdc++.h>usingnamespacestd;// Function to find problems not// solved at the end of Nth dayintproblemsLeft(intK, intP, intN){    if(K <= P)        return0;    else        return(K - P) * N;}// Driver Codeintmain(){    intK, P, N;    K = 4;    P = 1;    N = 10;    cout << problemsLeft(K, P, N);    return0;} | 
Java
| // Java program to find problems not// solved at the end of Nth dayclassGfg {    // Function to find problems not    // solved at the end of Nth day    publicstaticintproblemsLeft(intK, intP, intN)    {        if(K <= P)            return0;        else            return((K - P) * N);    }    // Driver Code    publicstaticvoidmain(String args[])    {        intK, P, N;        K = 4;        P = 1;        N = 10;        System.out.println(problemsLeft(K, P, N));    }} | 
Python3
| # Python program to find problems not# solved at the end of Nth daydefproblemsLeft(K, P, N):    if(K<=P):        return0    else:        return((K-P)*N)# Driver CodeK, P, N =4, 1, 10print(problemsLeft(K, P, N)) | 
C#
| // C# program to find problems not// solved at the end of Nth dayusingSystem;classGFG {// Function to find problems not// solved at the end of Nth daypublicstaticintproblemsLeft(intK,                               intP, intN){    if(K <= P)        return0;    else        return((K - P) * N);}// Driver CodepublicstaticvoidMain(){    intK, P, N;    K = 4;    P = 1;    N = 10;    Console.WriteLine(problemsLeft(K, P, N));}}// This code is contributed by vt_m | 
PHP
| <?php// PHP program to find problems not// solved at the end of Nth day// Function to find problems not// solved at the end of Nth dayfunctionproblemsLeft($K, $P, $N){    if($K<= $P)        return0;    else        return($K- $P) * $N;}// Driver Code$K= 4;$P= 1;$N= 10;echoproblemsLeft($K, $P, $N);// This code is contributed by anuj_67?> | 
Javascript
| <script>// JavaScript program to find problems not// solved at the end of Nth day// Function to find problems not// solved at the end of Nth dayfunctionproblemsLeft( K, P, N){    if(K <= P)        return0;    else        return(K - P) * N;}// Driver Codelet K, P, N;    K = 4;    P = 1;    N = 10;document.write(problemsLeft(K, P, N));// This code is contributed by rohitsingh07052.</script> | 
Output: 
30
Time Complexity: O(1)
Auxiliary Space: O(1)
                                            Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
You’ll access excellent video content by our CEO, Sandeep Jain, tackle common interview questions, and engage in real-time coding contests covering various DSA topics. We’re here to prepare you thoroughly for online assessments and interviews.
Ready to dive in? Explore our free demo content and join our DSA course, trusted by over 100,000zambiatek! Whether it’s DSA in C++, Java, Python, or JavaScript we’ve got you covered. Let’s embark on this exciting journey together!
You’ll access excellent video content by our CEO, Sandeep Jain, tackle common interview questions, and engage in real-time coding contests covering various DSA topics. We’re here to prepare you thoroughly for online assessments and interviews.
Ready to dive in? Explore our free demo content and join our DSA course, trusted by over 100,000zambiatek! Whether it’s DSA in C++, Java, Python, or JavaScript we’ve got you covered. Let’s embark on this exciting journey together!
 
				 
					


