fork(2) download
  1. upto = 20
  2.  
  3. def prime? x
  4. (2..x-1).each { |y| return false if x % y == 0 }
  5. true
  6. end
  7.  
  8. # For speed reasons we want to find max possible increment
  9. def increment upto
  10. a = 1
  11. (1..upto).each { |x| a*= x if prime? x }
  12. a
  13. end
  14.  
  15. def no_remainder? x, upto
  16. (1..upto).each { |y| return false if x % y != 0 }
  17. true
  18. end
  19.  
  20. increment = increment upto
  21. x = increment
  22. try_number = 1
  23.  
  24. while true
  25. if no_remainder? x, upto
  26. puts "The smallest number is #{x}"
  27. break
  28. end
  29. try_number += 1
  30. x = try_number * increment
  31. end
  32.  
Success #stdin #stdout 0s 4716KB
stdin
Standard input is empty
stdout
The smallest number is 232792560