Created
February 16, 2015 14:10
-
-
Save hachibeeDI/2540e7d00ffd2691ac5e to your computer and use it in GitHub Desktop.
リボの手数料の雑な算出
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ammount = process.argv[2] | |
each = process.argv[3] | |
interest = if process.argv[4] == undefined then 15.0 else process.argv[4] | |
interest_each_month = (interest / 12) / 100 | |
# console.log interest_each_month | |
# console.log ammount * interest_each_month | |
i = 0 | |
ammount = ammount - each | |
ammount_of_commission = 0 | |
console.log '----- ', i, ' ------' | |
console.log "ammo: ", ammount | |
console.log "commi: ", ammount_of_commission | |
while ammount >= 0 | |
i = i + 1 | |
commission = Math.round(ammount * interest_each_month) | |
ammount_of_commission += commission | |
ammount = ammount + commission | |
console.log '----- ', i, ' ------' | |
console.log "ammo: ", ammount | |
console.log "commi: ", commission | |
if ammount <= each | |
console.log ammount | |
break | |
ammount = ammount - each | |
console.log "ammo of commi: ", ammount_of_commission |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment