Skip to content

Commit

Permalink
Suggestion from keiravillekode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanplusplus committed Sep 29, 2024
1 parent b9bdea9 commit b8d5bbe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions exercises/practice/palindrome-products/.meta/example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ local function smallest(min, max)
for j = i, max do
local n = i * j

if n <= value and is_palindrome(n) then
if n > value then
break
end

if is_palindrome(n) then
if n ~= value then
value = n
factors = {}
Expand All @@ -48,7 +52,11 @@ local function largest(min, max)
for j = i, min, -1 do
local n = i * j

if n >= value and is_palindrome(n) then
if n < value then
break
end

if is_palindrome(n) then
if n ~= value then
value = n
factors = {}
Expand Down

0 comments on commit b8d5bbe

Please sign in to comment.