Skip to content

Instantly share code, notes, and snippets.

@CharlesFainLehman
Created September 9, 2010 21:18
Show Gist options
  • Save CharlesFainLehman/572597 to your computer and use it in GitHub Desktop.
Save CharlesFainLehman/572597 to your computer and use it in GitHub Desktop.
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