Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | Integer ** method

  • Last Updated : 07 Jan, 2022

The ** is an inbuilt method in Ruby returns the a number raised to the power of other number. It returns num1 ^ num2. 
 

Syntax: num1 ** num2
Parameters: The function accepts no parameter.
Return Value: It returns num1 ^ num2 
 

Example 1
 

Ruby




# Ruby program for ** method in Integer
   
# Initialize numbers
num1 = 2
num2 = 3
 
# Prints raised power
print num1 ** num2

Output
 

8

Example 2
 

Ruby




# Ruby program for ** method in Integer
   
# Initialize numbers
num1 = 5
num2 = 3
 
# Prints raised power
print num1 ** num2

Output
 

125

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!