Advertisement
Spocoman

04. Sequence 2k+1

Sep 10th, 2023
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.20 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int num, k = 1;
  7.     cin >> num;
  8.  
  9.     while (k <= num) {
  10.         cout << k << endl;
  11.         k = 2 * k + 1;
  12.     }
  13.  
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement