Advertisement
NonplayerCharacter

IIFE | Sum all numbers up to a limit

Apr 19th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // IIFE to sum all numbers up to a limit.
  2. // https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF
  3. // In this case, the limit is 100:
  4. (function(N){ return ( N * ( N+1 )) / 2;})(100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement