用于模运算的 Python 程序
给定三个数 x、y 和 z,我们的任务是计算 (x^y) % z
示例
Input: x = 2, y = 3, p = 3 Output: 2
说明 : 2^3 % 3= 8 % 3 = 2.
算法
Step 1: Input three numbers. Step 2: then we use pow() to calculating power and % for modular. Step 3: display result.
示例代码
x = int(input("Enter First Value ::>"))
y = int(input("Enter Second Value ::>"))
z= (int)(1e9+7)
# pow function use
d = pow(x, y) % z
print ("Value Is=",d)
输出
Enter First Value ::> 2 Enter Second Value ::> 3 Value Is= 8
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP