Skip to content

Instantly share code, notes, and snippets.

@GraphBear
Created February 6, 2016 19:55
Show Gist options
  • Save GraphBear/853dfeaf620028216242 to your computer and use it in GitHub Desktop.
Save GraphBear/853dfeaf620028216242 to your computer and use it in GitHub Desktop.
triangular number
def trinum(n):
# calculates the "triangular number" of a number
# https://www.mathsisfun.com/algebra/triangular-numbers.html
return n*(n+1)/2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment