红宝石 |整数**方法
**是 Ruby 中的一个内置方法,它返回一个数字的其他数字的幂。它返回 num1 ^ num2。
Syntax: num1 ** num2
Parameters: The function accepts no parameter.
Return Value: It returns num1 ^ num2
示例 1 :
Ruby
# Ruby program for ** method in Integer
# Initialize numbers
num1 = 2
num2 = 3
# Prints raised power
print num1 ** num2
Ruby
# Ruby program for ** method in Integer
# Initialize numbers
num1 = 5
num2 = 3
# Prints raised power
print num1 ** num2
输出:
8
示例 2 :
红宝石
# Ruby program for ** method in Integer
# Initialize numbers
num1 = 5
num2 = 3
# Prints raised power
print num1 ** num2
输出:
125