Write a Program to print given series:1 2 4 8 16 32 64 128... Test Case 1 Input (stdin) 5 Expected Output 1 2 4 8 16 Test Case 2 Input (stdin) 7 Expected Output 1 2 4 8 16 32 64
#include <iostream> using namespace std; int main() { int n,i,pro=1; cin>>n; cout<<"1 "; for(i=1;i<n;i++) { pro=pro*2; cout<<pro<<" "; } return 0; }