Created
September 9, 2010 21:18
-
-
Save CharlesFainLehman/572597 to your computer and use it in GitHub Desktop.
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
def mean(set) | |
set.length < 2 ? set[0] : (set[0] + mean set[1..set.length]) / set.length.to_f | |
end | |
def sigma(set) | |
set.length < 2 ? set[0] : set[0] + sigma set[1..set.length] | |
end | |
def is_prime?(val, c=(val-1)) | |
c < 2 or c >= val ? false : (val/(c.to_f)) - (val/c) == 0 ? false : is_prime?(val, c - 1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment