Skip to content

Instantly share code, notes, and snippets.

@marcin119a
Created February 27, 2017 20:13
Show Gist options
  • Save marcin119a/802d9b25e832e10f5caad77a213a7fc8 to your computer and use it in GitHub Desktop.
Save marcin119a/802d9b25e832e10f5caad77a213a7fc8 to your computer and use it in GitHub Desktop.
cpp pell
#include <iostream>
int pell(int n)
{
int n2 = 2, n1 = 2;
for(int i=0;i<n;i++)
{
n1 = n2;
n2 = n1 * 2 + n2;
}
return n2;
}
int main()
{
int n = 10;
pell(10);
std::cout << pell(10) << " " << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment