当前位置:网站首页>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)边栏推荐
- 用STM32点个灯
- A problem and solution of recording QT memory leakage
- Sword finger offer 53 - I. find the number I in the sorted array
- Zzulioj 1673: b: clever characters???
- Add level control and logger level control of Solon logging plug-in
- Solution to game 10 of the personal field
- PC寄存器
- ssh免密登录设置及使用脚本进行ssh登录并执行指令
- On the characteristics of technology entrepreneurs from Dijkstra's Turing Award speech
- Haut OJ 1401: praise energy
猜你喜欢
![[article de jailhouse] jailhouse hypervisor](/img/f4/4809b236067d3007fa5835bbfe5f48.png)
[article de jailhouse] jailhouse hypervisor

F - Two Exam(AtCoder Beginner Contest 238)

sync.Mutex源码解读

【Jailhouse 文章】Jailhouse Hypervisor
![[cloud native] record of feign custom configuration of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)
[cloud native] record of feign custom configuration of microservices

AtCoder Grand Contest 013 E - Placing Squares

Fried chicken nuggets and fifa22

Palindrome (csp-s-2021-palin) solution

SAP method of modifying system table data

Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
随机推荐
Sword finger offer 53 - ii Missing numbers from 0 to n-1
个人开发的渗透测试工具Satania v1.2更新
读者写者模型
Talking about JVM (frequent interview)
ALU逻辑运算单元
SAP-修改系统表数据的方法
Use of room database
On-off and on-off of quality system construction
API related to TCP connection
kubeadm系列-02-kubelet的配置和启动
Bit mask of bit operation
Sword finger offer 58 - ii Rotate string left
Web APIs DOM node
[jailhouse article] look mum, no VM exits
Configuration and startup of kubedm series-02-kubelet
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
过拟合与正则化
Introduction to convolutional neural network
Software test -- 0 sequence
Zzulioj 1673: b: clever characters???