shouldn't here be a check for positive integer? It doesn't hurt in ruby and the function would be more robust.