python - 我如何从递归函数中获得两个数字的 GCD?

标签 python

我们可以从递归函数中获得两个数字的 GCD 吗? 就像a和b一样

def recursive_f_gcb(a,b):

最佳答案

def recursive_f_gcd(a, b):
    if b==0:
        return a
    else:
        return recursive_f_gcd(b, a%b) 
a=18
b=12
print(recursive_f_gcd(a, b))

关于python - 我如何从递归函数中获得两个数字的 GCD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45532306/

相关文章:

python - 错误 : Setup script exited with error: command 'gcc' failed with exit status 1

python - 整数和整数的正则表达式?

Python导入模块函数

python - 使用循环来减少代码并使用 tkinter 删除图像

python - scipy.stats 上的导入错误

python - 使用 python 支持编译 vim

Python - 无法导入名称 View 键

python - 一段python代码如何判断它是否在unittest下运行

python - 将 PyTorch 张量转换为 python 列表

python - 由于动态变量,在 Python 中高效地创建列表