Created
June 22, 2011 20:55
-
-
Save nthj/1041160 to your computer and use it in GitHub Desktop.
npa function for calculating gross receipts when adding customers over a certain duration
This file contains 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
# n = number of additional customers per period | |
# p = amount each customer is charged per period | |
# a = duration of period to calculate total gross for | |
# | |
# example: customer every 2 weeks, 25 per month, after 6 months: (fn).call(2, 25, 6) | |
# => 1050 | |
->(n, p, a) { t = 0; a.times { |i| t += (i + 1) * p * n }; t } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment