Created
May 12, 2012 20:17
-
-
Save rhysd/2668745 to your computer and use it in GitHub Desktop.
euler1
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
#include <iostream> | |
constexpr int f( int n, int i ) | |
{ | |
return n<=0 ? 0 : (n + f(n-i, i)); | |
} | |
static constexpr int MAX = 1000 - 1; | |
int main() | |
{ | |
constexpr int i3 = MAX - MAX % 3; | |
constexpr int i5 = MAX - MAX % 5; | |
std::cout << f(i3, 3) + f(i5, 5) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment