Last active
June 12, 2021 19:33
-
-
Save ttsugriy/d456d06001cbfa1e283475e8afbd8fa9 to your computer and use it in GitHub Desktop.
Sum of N
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
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