Created
February 27, 2017 20:13
-
-
Save marcin119a/802d9b25e832e10f5caad77a213a7fc8 to your computer and use it in GitHub Desktop.
cpp pell
This file contains hidden or 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> | |
| 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