Skip to content

Commit a362a72

Browse files
committed
Add solutions
1 parent 275d937 commit a362a72

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

projecteuler/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
| 87 | Prime power triples | :small_blue_diamond: [Python](../projecteuler/python/p087.py)
8383
| 92 | Square digit chains | :small_orange_diamond: [Python](../projecteuler/python/p092.py)
8484
| 97 | Large non-Mersenne prime | :small_blue_diamond: [Python](../projecteuler/python/p097.py)
85+
| 145 | How many reversible numbers are there below one-billion? | :small_orange_diamond: [Lua](../projecteuler/python/p145.py)
8586
| 205 | Dice game | :small_blue_diamond: [Python](../projecteuler/python/p205.py)
8687
| 206 | Concealed square | :small_orange_diamond: [Python](../projecteuler/python/p206.py)
8788
| 243 | Resilience | :small_orange_diamond: [Python](../projecteuler/python/p243.py) :small_orange_diamond: [Lua](../projecteuler/lua/p243.lua)

projecteuler/lua/p145.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function reverseSum(n)
2+
return n + string.reverse(n)
3+
end
4+
5+
function isAllOdd(n)
6+
for digit in string.gmatch(math.floor(n), '%d') do
7+
if digit % 2 == 0 then
8+
return false
9+
end
10+
end
11+
return true
12+
end
13+
14+
count = 0
15+
for i = 1, 10 ^ 9 do
16+
if i % 10 ~= 0 and isAllOdd(reverseSum(i)) then
17+
count = count + 1
18+
end
19+
end
20+
print(count)

0 commit comments

Comments
 (0)