Skip to content

Instantly share code, notes, and snippets.

@peterssonjesper
Created August 18, 2012 16:38
Show Gist options
  • Save peterssonjesper/3388238 to your computer and use it in GitHub Desktop.
Save peterssonjesper/3388238 to your computer and use it in GitHub Desktop.
#include <iostream>
void tree(int d, int n);
long long int found = 0;
int target = 1000000;
void tree(int d, int n) {
if(d > target)
return;
found += 1;
tree(2*d-n, d);
tree(2*d+n, d);
tree(d+2*n, n);
}
int main() {
tree(2, 1);
tree(3, 1);
std::cout << "The answer is " << found << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment