Permalink
Browse files

problem 20

  • Loading branch information...
1 parent 767a981 commit e1dbb1efa74cba1629d9c2433c94c6c94acbffe2 @twymer committed Jun 1, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 ruby/p20.rb
View
@@ -0,0 +1,6 @@
+# Problem 20
+# I really like using inject..
+
+n = 100
+factorial = (1..n).inject(:*)
+puts factorial.to_s.split(//).inject(0) { |sum, char| sum + char.to_i }

0 comments on commit e1dbb1e

Please sign in to comment.