Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def my_collect
- t = (286..100000).collect{|i| i*(i+1)/2 }
- p = (166..100000).collect{|i| i*(3*i-1)/2 }
- h = (144..100000).collect{|i| i*(2*i-1) }
- res=(t&p&h).first
- puts res
- end
- def my_each
- p=h=t=[]
- (144..100000).each{|i|
- t.push( i*(i+1)/2 ) if i>285
- p.push( i*(3*i-1)/2 ) if i>165
- h.push( i*(2*i-1) ) if i>144
- }
- res=(t&p&h).first
- puts res
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement