From 3515f622440f576923e87a8e6f189688a7ead345 Mon Sep 17 00:00:00 2001 From: Junyu0707 Date: Fri, 16 Jan 2026 12:30:07 -0500 Subject: [PATCH] Add square, cube, and square_n_times functions --- calculator.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/calculator.py b/calculator.py index 24a2fef..77f2434 100644 --- a/calculator.py +++ b/calculator.py @@ -13,4 +13,20 @@ def divide(a,b): print("I'm going use the calculator functions to multiply 5 and 6") x = multiply(5,6) -print(x) \ No newline at end of file +print(x) + +def square(x): + return x ** 2 + + +def cube(x): + return x ** 3 + + +def square_n_times(number, n): + total = 0 + current = number + for _ in range(n): + current = square(current) + total += current + return total \ No newline at end of file