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
class << Math | |
# Checa se um número é primo ou não. | |
# | |
# value - Valor que deverá ser checado | |
# checksByThread - Quantidade de checagens por thread. | |
# Ajuda a driblar o processamento com valores menores | |
# Ajuda a driblar a utilização de recursos com valores maiores | |
# | |
def isPrime?(value, checksByThread = 10**10) | |
# Rotina para checagem de número primos |
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
# Algoritmo de Logaritmo | |
# Autor: Gabriel "Gab!" Teles <gab dot teles at hotmail dot com> | |
# Data: 2013-04-26 | |
def log(n, m) | |
# Verifica valores de entrada | |
if m == 0 # Não existe logaritmo de 0, logo, adequa valor | |
# ao retornado pelo Math.log: -Infinity | |
return -1.0/0.0 |
NewerOlder