power of 3 sequences

hi, pals!
do you guys know how to write a program that prints out a sequence of power of 3?
the user input is the limit of the sequence
e.g. : the input : 4 100 ------>> the output : 9 27 81
1
2
3
4
5
6
7
int min, max, i;
cin >> min;
cin >> max;

for (i = 1; i < max ; i*=3)
  if (i > min) 
    cout << i << " ";


I think this would work.
thanks it helped :)
Topic archived. No new replies allowed.