Skip to content

Instantly share code, notes, and snippets.

@nistude
nistude / prime_factors_2_spec.rb
Created July 4, 2012 05:14 — forked from shostakovich/prime_factors_2_spec.rb
PrimeFactors Kata Second iteration
module PrimeFactors
def decompose(number)
if number <= 3
[number]
else
prime_factors = []
(2..number / 2).each do |prime|
while(number % prime).zero? do
number = number / prime
prime_factors << prime