+ 3
How do you this in code? (Exchang money by using 10$ , 5$, 2$ and 1$, Input = 13, Ex: 13$ = 10$ + 2$ +1$)
6 Réponses
+ 4
You have to divide you money for largest "piece" (10,5,2,1) for get the number of nth piece... After, you have to subtract number of nth piece from total money and repeat all starting with remaining money and next largest piece. Ex:
13 / 10= 1 ==> 13-(10*1)= 3
3/5 = 0 ==> 3-(5*0)=3
3/2= 1 ==> 3-(2*1)= 1
1/1= 1 ==> 1-(1*1)= 0
+ 4
Ketan Lalcheta Yes, i know that but i think for understanding purpose is better use subtraction method
+ 3
KrOW to get output of remianing balance after division, you can use % operator... 13%10 = 3 and so on... substract method also work fine whatever you have mentioned
+ 2
i made this a while back. With a few small changes it should be what you are looking for.
https://code.sololearn.com/cwFDDBLW9764/?ref=app
+ 2
Thank you all for your help!✌
0
https://medium.com/@osagienoah04/fathomable-JUMP_LINK__&&__python__&&__JUMP_LINK-programming-beginner-to-advance-d02bdc5474bc check it out and give it a clap. Thanks...