SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
47 stars 132 forks source link

created kth not divisible by n #312

Closed ak-create closed 2 years ago

ak-create commented 2 years ago

Issue Id you have worked upon -

308

Briefly explain your program logic -

if value of n and k given in the problem then simply we have to print n+1 and if value of k=1 then simply print 1 itself because 1 is not divisible by any no >=1. and else you can simply divide k by (n-1) from that you can get how many no. which are not divisible by n and if you need kth no. then u simply add k + remainder of k/(n-1) to k/(n-1). and there is edge case if remainder is 0 then u have to subtract the final value by -1 and print it.

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here image image


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -