Skip to content

Instantly share code, notes, and snippets.

@dkindler
Created August 19, 2015 19:56
Show Gist options
  • Save dkindler/6347e33f067c551f4b82 to your computer and use it in GitHub Desktop.
Save dkindler/6347e33f067c551f4b82 to your computer and use it in GitHub Desktop.
#######ERROR#############
ruby 3.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- euler-help (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from 3.rb:5:in `<main>'
#######CODE#############
require 'euler-help'
lpf, num = 0, 600851475143
1.upto(Math.sqrt(num).to_i) do |n|
if num % n == 0
lpf = n if n.prime?
end
end
#######Imported Code#############
class Integer
def prime?
return false if self <= 1
return true if self == 2
return false if self % 2 == 0
2.upto((self/2).to_i) do |i|
return false if self % i == 0
end
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment