Skip to content

Instantly share code, notes, and snippets.

@nthj
Created June 22, 2011 20:55
Show Gist options
  • Save nthj/1041160 to your computer and use it in GitHub Desktop.
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
# 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