Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created July 28, 2012 05:26
Show Gist options
  • Save yuuki/3191919 to your computer and use it in GitHub Desktop.
Save yuuki/3191919 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
n = (1..100).each.inject {|sum, i| sum + i }
r = (1..100).each.inject {|sum, i| sum + i**2 }
puts n**2 - r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment