SHARE
TWEET

Untitled

a guest Dec 6th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #1
  2. largest_num = 0
  3.  
  4. (1..999).each do |i|
  5.     (2..999).each do |j|
  6.         if (i*j).to_s == (i*j).to_s.reverse
  7.             largest_num = i*j if i*j > largest_num
  8.         end
  9.     end
  10. end
  11.  
  12. puts largest_num
  13.  
  14. #2
  15. ans = 1
  16. (1..20).each do |i|
  17.     ans = (ans * i)/ans.gcd(i)
  18. end
  19. puts ans
  20.  
  21. #3
  22. (1..1000).each do |a|
  23.     (2..1000).each do |b|
  24.         c = 1000 - a - b
  25.         if a**2 + b**2 == c**2 && b > a && c > b
  26. #           puts a,b,c
  27.             puts a * b * c
  28.         end
  29.     end
  30. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top