Given indices are just repeated multiplication, you could use the for loop to progressively multiply it.

Something like:

n = 5
runningPower = 1
for i in range(n + 1):
  runningPower *= 2
  print(runningPower)
Answer from zjb on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › write-you-own-power-without-using-multiplication-and-division
Write you own Power without using multiplication(*) and division(/) operators - GeeksforGeeks
Interview Corner · DSA Python · Last Updated : 23 Jul, 2025 · Method 1 (Using Nested Loops): We can calculate power by using repeated addition. For example to calculate 5^6. 1) First 5 times add 5, we get 25.
Published   July 23, 2025
Discussions

[Python] Im trying to make a program that manually calculates powers without the use of ** or any other function. Help?
Your formula is completely off. There are not additions in powers. a3 = a * a * a, a4 = a * a * a * a Think about how you can convert that into a loop. You take a starting point a, then, you multiply that starting point with a, next time, you again multiply the result from before by a, and so on until you have your power. Also, why are you using eval? You should make explicit type conversions using int or float. total should either start at a or at 1, not at 0. More on reddit.com
🌐 r/learnprogramming
10
1
September 7, 2022
How to raise a number to the power of another without Math.pow() ?
You might want to see if a for loop would be useful. More on reddit.com
🌐 r/learnjava
8
2
November 18, 2016
🌐
DataCamp
datacamp.com › tutorial › exponents-in-python
Exponents in Python: A Comprehensive Guide for Beginners | DataCamp
November 25, 2024 - Squaring in Python is easy: Use the in-built ** operator or try NumPy, pow(), math.pow(), bitwise operators, and other functions for more versatile solutions. ... Many Python users are familiar with using asterisks for multiplication and power operators, but in this tutorial, you'll find out additional ways on how to apply the asterisk.
🌐
W3Schools
w3schools.com › python › ref_func_pow.asp
Python pow() Function
Built-in Modules Random Module ... Q&A Python Bootcamp Python Certificate Python Training ... The pow() function returns the value of x to the power of y (xy)....
🌐
Quora
quora.com › How-do-I-make-a-number-an-exponent-of-another-in-Python-without-using-the-inbuilt-‘**’-or-the-‘math-pow’
How to make a number an exponent of another in Python ...
Answer (1 of 4): There are many ways to approach this. Just write your own function! [code]def power(a,b): res = 1 for i in range(b): res *= a return res [/code]This is one of the snippets which works and returns a^b.
🌐
Zero To Mastery
zerotomastery.io › blog › python-exponent
Beginner's Guide to Python Exponents (With Code Examples) | Zero To Mastery
November 8, 2024 - This flexibility is invaluable in data analysis, allowing you to model complex changes quickly without recalculating each scenario by hand. As you’ve seen, exponents are more than just math—they’re a powerful way to simplify complex calculations and make your code cleaner and faster. Whether you’re automating financial models, analyzing data, or tackling scientific problems, Python...
Find elsewhere
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
In Python 3 without the Math package, what is the equivalent of ceiling and floor? - Raspberry Pi Forums
November 16, 2022 - Mathematica · High Altitude Balloon · Weather station · Programming · C/C++ Java · Python · Scratch · Other programming languages · Windows 10 for IoT · Wolfram Language · Bare metal, Assembly language · Graphics programming · OpenGLES · OpenVG ·
🌐
Ben
ben.land › post › 2021 › 02 › 24 › power-without-math-lib
Implementing exponentiation without a standard math library | ben.land
This results in the following implementation, where the ftol parameter sets the maximum value the next term can take before the calculation terminates. Note the use of ipow from earlier to compute the integer powers.
🌐
TutorialsPoint
tutorialspoint.com › how-to-perform-square-root-without-using-math-module-in-python
How to perform square root without using math module in Python?
Without using the math module, the simplest approach to find the square root of a number in Python is to use the built-in exponential operator ** (It is an exponent operator because it calculates the power of the first operand to the power of the second operand).
🌐
Real Python
realpython.com › python-math-module
The Python math Module: Everything You Need to Know – Real Python
October 21, 2023 - For straightforward mathematical ... (/), and multiplication (*). But more advanced operations, such as exponential, logarithmic, trigonometric, or power functions, are not built in....
🌐
Tutorial Gateway
tutorialgateway.org › python-pow
Python pow Function
March 31, 2025 - The Python pow function is used to calculate the Power of the specified expression and the syntax it is ... Base: Please specify the base value here. Exponent: Please specify the Exponent value or power here.
🌐
Quora
quora.com › What-is-the-code-behind-the-math-pow-function
What is the code behind the math.pow function? - Quora
Answer (1 of 4): [code]Public static int pow(int num, int pow) { int ans =num; if (pow ==1) { return num; } else if (i==0) { return 1; } for(int i =1, i!= pow, i++) { ans = ans*num; } return ans; } // I think this is it. This code does not deal // with negative exponents or frac...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › pow
Math.pow() - JavaScript | MDN
In addition, the behavior where base is 1 and exponent is non-finite (±Infinity or NaN) is different from IEEE 754, which specifies that the result should be 1, whereas JavaScript returns NaN to preserve backward compatibility with its original behavior. Because pow() is a static method of Math, use it as Math.pow(), rather than as a method of a Math object you created (Math is not a constructor).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-find-power-of-a-number
Python program to find power of a number - GeeksforGeeks
July 23, 2025 - This is the simplest and most Pythonic way to calculate the power of a number. The ** operator is internally optimized and is the preferred choice for most situations.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-square-a-number-in-python-squaring-function
How to Square a Number in Python – Squaring Function
May 31, 2022 - You can directly multiple a number by itself (number * number) but in this article, I'll show you three ways you can do this without hardcoding both numbers. ... ** is called the power operator.
🌐
Automate the Boring Stuff
automatetheboringstuff.com › 3e › chapter1.html
Chapter 1 - Python Basics, Automate the Boring Stuff with Python, 3rd Ed
Be sure you don’t run python on ... Python 2.7 is not recommended. Exit the 2.7 interactive shell and run python3 instead. Enter 2 + 2 at the prompt to have Python do some simple math....
🌐
W3Schools
w3schools.com › python › ref_math_pow.asp
Python math.pow() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... # Import math Library import math #Return the value of 9 raised to the power of 3 print(math.pow(9, 3)) Try it Yourself »
🌐
Vultr Docs
docs.vultr.com › python › built-in › pow
Python pow() - Exponentiation Function | Vultr Docs
November 22, 2024 - Explore practical examples that demonstrate how to use this function not only for basic exponentiation but also in situations requiring modulo operations. Define the base and the exponent. Use the pow() function to compute the power.
🌐
DataCamp
datacamp.com › tutorial › python-square
How to Square a Number in Python: Basic and Advanced Methods | DataCamp
June 28, 2024 - The simplest way to square a number is using the multiplication operator 5 * 5. The pow() function is an in-built Python function to square a number. It also supports a third argument, the modulo.