蓝桥杯Python组中,如何求一个数的既约分数?
- 内容介绍
- 文章标签
- 相关推荐
本文共计131个文字,预计阅读时间需要1分钟。
蓝桥杯Python组——约分+import os+import sys+import math+
蓝桥杯python组——既约分数
import osimport sys
import math #math.gcd()方法 它接受两个整数并返回其最大公约数
count = 0
for i in range(1,2021):
for j in range(1,2021):
if math.gcd(i,j) == 1:
#print("{}/{}".format(i,j))
count += 1
print(count)
答案为2481215
谢谢大家的支持,您的一键三连是 罡罡同学前进的最大动力!
本文共计131个文字,预计阅读时间需要1分钟。
蓝桥杯Python组——约分+import os+import sys+import math+
蓝桥杯python组——既约分数
import osimport sys
import math #math.gcd()方法 它接受两个整数并返回其最大公约数
count = 0
for i in range(1,2021):
for j in range(1,2021):
if math.gcd(i,j) == 1:
#print("{}/{}".format(i,j))
count += 1
print(count)
答案为2481215
谢谢大家的支持,您的一键三连是 罡罡同学前进的最大动力!

