How we can do a program of x raise to n ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How we can do a program of x raise to n ??

18th Aug 2019, 5:14 AM
Raj
2 Answers
+ 9
You can simply use ** operator to raise x to power of n, (x**n), alternatively you can use pow() function https://www.google.com/amp/s/www.geeksforgeeks.org/pow-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
18th Aug 2019, 6:17 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
Using Power Operator (**), like this if x = 2 x ** 2 = 4 In JavaScript we also call it Exponentiation operator introduced in ES 2016
18th Aug 2019, 5:41 AM
Bug Slayer