daily pastebin goal
24%
SHARE
TWEET

Fibonacci Arbitrarily large size

GHJGHJJHG Nov 19th, 2017 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <gmpxx.h>
  3. #include <limits>
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9.     mpz_class last = 0, current = 1, next;
  10.  
  11.     for (unsigned short i = 0; i < USHRT_MAX; i++) {
  12.         next = current + last;
  13.         last = current;
  14.         current = next;
  15.     }
  16.  
  17.     std::cout << "Previous: " + current.get_str() + "\nLast: " + last.get_str()
  18.               << std::endl;
  19. }
RAW Paste Data
Top