Skip to content

Instantly share code, notes, and snippets.

@ttsugriy
Last active June 12, 2021 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttsugriy/d456d06001cbfa1e283475e8afbd8fa9 to your computer and use it in GitHub Desktop.
Save ttsugriy/d456d06001cbfa1e283475e8afbd8fa9 to your computer and use it in GitHub Desktop.
Sum of N
template<class T>
T sum_of_n (T n) {
T total = 0;
for (T i = 1; i <= n; ++i) total += i;
return total;
}
template unsigned int sum_of_n<unsigned int>(unsigned int n);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment