Skip to content

Instantly share code, notes, and snippets.

@fakefarm
Created April 17, 2012 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakefarm/2405727 to your computer and use it in GitHub Desktop.
Save fakefarm/2405727 to your computer and use it in GitHub Desktop.
Euler problem 3
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143 ?
number = 24
array = []
# how do I iterate a number? Is that a loop?
array.each do |num|
if num % 1 == 0
array << 1
else num % 2 == 0
array << 2
end
end
puts array
# ERROR: undefined method `each' for 24:Fixnum (NoMethodError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment