Skip to content

Instantly share code, notes, and snippets.

@masahixixi
Created September 17, 2012 08:33
Show Gist options
  • Save masahixixi/3736192 to your computer and use it in GitHub Desktop.
Save masahixixi/3736192 to your computer and use it in GitHub Desktop.
ProjectEuler #5
lcmnum = 11
(12..20).each do |num|
lcmnum = lcmnum.lcm(num)
end
p lcmnum
@yujinakayama
Copy link

問題文は、

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

なので、11〜20みたいな小細工は必要ないと思う。
よっぽどパフォーマンスが求められている状況でない限り、汎用的でない最適化はあまりよろしくないかと。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment