Skip to content

Instantly share code, notes, and snippets.

@rhysd
Created May 12, 2012 20:17
Show Gist options
  • Save rhysd/2668745 to your computer and use it in GitHub Desktop.
Save rhysd/2668745 to your computer and use it in GitHub Desktop.
euler1
#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