Created
December 5, 2011 14:00
-
-
Save melborne/1433665 to your computer and use it in GitHub Desktop.
Exclamation Factorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "mathn" | |
| class Integer | |
| def ! | |
| (1..self).inject(:*) | |
| end | |
| end | |
| f1 = ->a,b,c{ a - b / c } | |
| f2 = ->a,b,c{ (a - b) / c } | |
| pp = ->abc{ | |
| print "(%i - %i) / %i = %i\n" % [*abc, f2[*abc]] | |
| print " %i - %i / %i = %i! = %i\n\n" % [*abc, f2[*abc], f1[*abc]] | |
| } | |
| [*2..1000].repeated_permutation(3) | |
| .select { |abc| f1[*abc] == f2[*abc].! } | |
| .each { |abc| pp[abc] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment