Advertisement
desislava_topuzakova

04. Even Powers of 2

Jan 29th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. //всички четни степени от 0 до n (0, 2, 4, 6, 8,..., n)
  10.  
  11. //for цикъл за степените
  12. //повтарям: отпечатвам 2 на дадена степен
  13. //начало: 0
  14. //край: n
  15. //промяна: +2
  16.  
  17. for (int power = 0; power <= n; power += 2)
  18. {
  19. cout << pow(2, power) << endl;
  20. }
  21. }
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement