Write a program that uses a while loop to determine the smallest integer power of 3 that exceeds 30 000. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Write a program that uses a while loop to determine the smallest integer power of 3 that exceeds 30 000.

In other words find the smallest value of n so that 3^n>30000.

13th May 2017, 7:46 AM
Tehreem
4 Answers
+ 3
#include <iostream> #include <cmath> using namespace std; int main() { int n = sqrt(30000); cout << ++n << endl; return 0; }
13th May 2017, 8:04 AM
visph
visph - avatar
+ 3
@Burey is right: even if it's non-efficient to do that way, that's what was asking ;P
13th May 2017, 8:46 AM
visph
visph - avatar
+ 1
a solution using a while loop as requested https://code.sololearn.com/cE8U21PeS0V1/?ref=app
13th May 2017, 9:37 AM
Volker Milbrandt
Volker Milbrandt - avatar