Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. import std.stdio;
  2.  
  3. void main()
  4. {
  5.     ulong p = 1;
  6.     ulong n = 2;
  7.     ulong sum = 0;
  8.     ulong temp;
  9.  
  10.     while (n < 4e9)
  11.     {
  12.         sum += n;
  13.  
  14.         temp = p + 2*n;
  15.         n = 2*p + 3*n;
  16.         p = temp;;
  17.     }
  18.  
  19.     writeln(sum);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement