当前位置:网站首页>One question per day 1447 Simplest fraction
One question per day 1447 Simplest fraction
2022-07-05 05:42:00 【A big pigeon】
topic : Give you an integer n , Please return to all 0 To 1 Between ( barring 0 and 1) Satisfy that the denominator is less than or equal to n Of Simplest fraction . The score can be in the form of arbitrarily Sequential return .
Explain : Find the simplest fraction , The greatest common divisor equivalent to denominator and numerator is 1.
class Solution:
def simplifiedFractions(self, n: int) -> List[str]:
res = []
for i in range(2,n+1):
for j in range(1,i):
if gcd(i,j) == 1:
ff = f"{j}/{i}"
res.append(ff)
return resgreatest common divisor gcd(a,b) yes Python Built in functions , You can use it directly .
gcd Recursive implementation of
def gcd(a,b):
return a if b == 0 else gcd(b, a%b)边栏推荐
- [practical skills] how to do a good job in technical training?
- High precision subtraction
- Software test -- 0 sequence
- Educational Codeforces Round 116 (Rated for Div. 2) E. Arena
- sync. Interpretation of mutex source code
- Introduction and experience of wazuh open source host security solution
- Little known skills of Task Manager
- 【云原生】微服务之Feign自定义配置的记录
- CF1637E Best Pair
- In this indifferent world, light crying
猜你喜欢

2017 USP Try-outs C. Coprimes

Introduction et expérience de wazuh open source host Security Solution

【实战技能】非技术背景经理的技术管理
![[cloud native] record of feign custom configuration of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)
[cloud native] record of feign custom configuration of microservices

读者写者模型
![[article de jailhouse] jailhouse hypervisor](/img/f4/4809b236067d3007fa5835bbfe5f48.png)
[article de jailhouse] jailhouse hypervisor

中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章

【Jailhouse 文章】Jailhouse Hypervisor

CF1634E Fair Share

剑指 Offer 35.复杂链表的复制
随机推荐
中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章
Demonstration of using Solon auth authentication framework (simpler authentication framework)
网络工程师考核的一些常见的问题:WLAN、BGP、交换机
Configuration and startup of kubedm series-02-kubelet
Hang wait lock vs spin lock (where both are used)
YOLOv5-Shufflenetv2
Individual game 12
Kubedm series-00-overview
Haut OJ 1401: praise energy
Sword finger offer 58 - ii Rotate string left
Wazuh開源主機安全解决方案的簡介與使用體驗
Sword finger offer 35 Replication of complex linked list
Convolution neural network -- convolution layer
Sword finger offer 05 Replace spaces
【Jailhouse 文章】Performance measurements for hypervisors on embedded ARM processors
【Jailhouse 文章】Jailhouse Hypervisor
Simple knapsack, queue and stack with deque
sync. Interpretation of mutex source code
Software test -- 0 sequence
Smart construction site "hydropower energy consumption online monitoring system"