Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Created December 24, 2009 11:07
Show Gist options
  • Save Riduidel/263147 to your computer and use it in GitHub Desktop.
Save Riduidel/263147 to your computer and use it in GitHub Desktop.
range = 1..100;
squareSum = range.inject (0, {sum, number ->
sum+=(number*number)
});
println squareSum;
sum = range.inject (0, {sum, number ->
sum+=(number)
});
sum *=sum;
println sum-squareSum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment