Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. int pell(int n)
  5. {
  6. int n2 = 2, n1 = 2;
  7.  
  8. for(int i=0;i<n;i++)
  9. {
  10. n1 = n2;
  11. n2 = n1 * 2 + n2;
  12.  
  13. }
  14. return n2;
  15.  
  16.  
  17. }
  18. int main()
  19. {
  20. int n = 10;
  21. pell(10);
  22.  
  23. std::cout << pell(10) << " " << std::endl;
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement