def factorize(number) do
test = factors(number)
Enum.filter(test,fn x -> prime?(x) == true end)
end
def prime?(n) do
[1,n] === factors(n)
end
def factors(1), do: [1]
def factors(n) when n < 1 do
"Please input a number greater than 0"
end
def factors(2), do: [1,2]
def factors(n) do
Enum.filter(1..floor(n/2), fn x -> rem(n,x) == 0 end) ++ [n]
end
I have these three functions and if I run factorize(13) or any other prime I get a '\r' or other random output and I don't understand why.