Linting
This commit is contained in:
parent
d5b21cacef
commit
972c716993
@ -8,18 +8,14 @@ Solution for Problem 4 of Project Euler
|
|||||||
https://projecteuler.net/problem=4 =#
|
https://projecteuler.net/problem=4 =#
|
||||||
|
|
||||||
using BenchmarkTools
|
using BenchmarkTools
|
||||||
using Profile
|
|
||||||
|
|
||||||
function ispalindrome(n::Int64)
|
|
||||||
# return digits(n) == reverse!(digits(n))
|
function ispalindrome(n)
|
||||||
for i in zip(digits(n), reverse!(digits(n)))
|
s = string(n)
|
||||||
if i[1] ≠ i[end]
|
s == reverse(s)
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Problem4()
|
function Problem4()
|
||||||
#=
|
#=
|
||||||
A palindromic number reads the same both ways. The largest palindrome made
|
A palindromic number reads the same both ways. The largest palindrome made
|
||||||
@ -28,10 +24,9 @@ function Problem4()
|
|||||||
Find the largest palindrome made from the product of two 3-digit numbers. =#
|
Find the largest palindrome made from the product of two 3-digit numbers. =#
|
||||||
|
|
||||||
ans = 10_001
|
ans = 10_001
|
||||||
for i in 100:999, j in i:999
|
for i = 100:999, j = i:999
|
||||||
num = i * j
|
if ((i * j > ans) && ispalindrome(i * j))
|
||||||
if (num > ans) && ispalindrome(num)
|
ans = i * j
|
||||||
ans = num
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ function Problem5()
|
|||||||
What is the smallest positive number that is evenly divisible by all of
|
What is the smallest positive number that is evenly divisible by all of
|
||||||
the numbers from 1 to 20? =#
|
the numbers from 1 to 20? =#
|
||||||
ans = 1
|
ans = 1
|
||||||
for i in 1:21
|
for i = 1:21
|
||||||
ans *= i ÷ gcd(i, ans)
|
ans *= i ÷ gcd(i, ans)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user