Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[local primes = {}
- local function isPrime(n)
- local cached = primes[n]
- if cached ~= nil then
- return cached
- end
- for i = 2, math.sqrt(n) do
- if n % i == 0 then
- primes[n] = false
- return false
- end
- end
- primes[n] = true
- return true
- end
- local function primeFactorization(n)
- local finale = {}
- local newNumber = n
- for i = 2, n do
- if isPrime(i) then
- while newNumber % i == 0 do
- finale[#finale + 1] = i
- newNumber = newNumber / i
- end
- end
- end
- return table.concat(finale, ", ")
- end]]
- local a={}local function b(c)local d=a[c]if d~=nil then return d end;for e=2,math.sqrt(c)do if c%e==0 then a[c]=false;return false end end;a[c]=true;return true end;return function(c)local g={}local h=c;for e=2,c do if b(e)then while h%e==0 do g[#g+1]=e;h=h/e end end end;return table.concat(g,", ")end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement