Skip to content

Commit

Permalink
Debug prime_functions
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 11, 2024
1 parent e0c152d commit 67cef94
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/src/lib/primes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ local function prime_factors(n)
local p = pgen.next()

local function next()
print(p .. ", " .. n)
while p ~= nil and n % p ~= 0
if n == 1
then
return nil
end

while p and n % p ~= 0
do
p = pgen.next()
end
Expand All @@ -66,7 +70,7 @@ local function prime_factors(n)
return -1
end

n = n / p
n = math.floor(n / p)
return p
end

Expand Down

0 comments on commit 67cef94

Please sign in to comment.