Guest User

Untitled

a guest
Feb 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. >> [x.to_s() | x in 1..10]
  2. => ["1","2","3","4","5","6","7","8","9","10"]
  3.  
  4. # Find Pythagorean triples
  5. >> n = 50
  6. => 50
  7. >> [(a,b,c) | a in 1..n, b in 1..n, c in 1..n, a+b+c <= n, a**2 + b**2 == c**2]
  8. => [(3,4,5),(4,3,5),(5,12,13),(6,8,10),(8,6,10),(8,15,17),(9,12,15),(12,5,13),(12,9,15),(12,16,20),(15,8,17),(16,12,20)]
Add Comment
Please, Sign In to add comment