multiply_3

multiply_3#

Write a function called multiply_3 that has one parameter called n. This function contains a while loop that continually multiplies a number n by 3 until it is greater than 100. The function should return the final value of n.

You can assume that every input value of n is greater than zero.

A step by step example of sample 1:

  • n = 10

  • Since n = 10 is not greater than 100, we multiply n by 3.

  • n = 10*3; n now equals 30

  • Since n = 30 is not greater than 100, we multiply n by 3.

  • n = 30 * 3; n now equals 90

  • Since n = 90 is not greater than 100, we multiply n by 3.

  • n = 90 * 3; n now equals 270

  • Since n = 270 is greater than 100, we return 270.

Notice that steps 2, 4, 6, and 8 are checking for the same condition and steps 3, 5, and 7 are all multiplying n by 3. Your task is to condense these steps into a while loop for any arbitrary value of n > 0.

Sample Input 1:

10

Sample Output 1:

270

Sample Input 2:

3

Sample Output 2:

243

Sample Input 3:

15

Sample Output 3:

135