Skip to content

Instantly share code, notes, and snippets.

@vlofgren
Created July 22, 2015 14:43
Show Gist options
  • Select an option

  • Save vlofgren/7d99b095d2714a578da0 to your computer and use it in GitHub Desktop.

Select an option

Save vlofgren/7d99b095d2714a578da0 to your computer and use it in GitHub Desktop.
// end range is the first number that shouldn't be included (to be in line with problem formulation)
constexpr int projecteuler1(int endRange) {
return (3*((endRange-1)/3)*((endRange-1)/3+1)
+ 5*((endRange-1)/5)*((endRange-1)/5+1)
- 15*((endRange-1)/15)*((endRange-1)/15+1))/2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment