Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Pythonに整数のリストがある場合、たとえばL = [4,8,12,24]、最大公約数/除数(この場合は4)をどのように計算できますか?
L = [4,8,12,24]
それを行う1つの方法は次のとおりです。
import fractions def gcd(L): return reduce(fractions.gcd, L) print gcd([4,8,12,24])