Linting
This commit is contained in:
parent
d5b21cacef
commit
972c716993
@ -18,7 +18,7 @@ function Problem1()
|
||||
Find the sum of all the multiples of 3 or 5 below 1000.
|
||||
=#
|
||||
|
||||
ans = sum(x for x in 0:999 if x%3==0 || x%5==0)
|
||||
ans = sum(x for x in 0:999 if x % 3 == 0 || x % 5 == 0)
|
||||
|
||||
return ans
|
||||
end
|
||||
|
@ -8,18 +8,14 @@ Solution for Problem 4 of Project Euler
|
||||
https://projecteuler.net/problem=4 =#
|
||||
|
||||
using BenchmarkTools
|
||||
using Profile
|
||||
|
||||
function ispalindrome(n::Int64)
|
||||
# return digits(n) == reverse!(digits(n))
|
||||
for i in zip(digits(n), reverse!(digits(n)))
|
||||
if i[1] ≠ i[end]
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
||||
function ispalindrome(n)
|
||||
s = string(n)
|
||||
s == reverse(s)
|
||||
end
|
||||
|
||||
|
||||
function Problem4()
|
||||
#=
|
||||
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. =#
|
||||
|
||||
ans = 10_001
|
||||
for i in 100:999, j in i:999
|
||||
num = i * j
|
||||
if (num > ans) && ispalindrome(num)
|
||||
ans = num
|
||||
for i = 100:999, j = i:999
|
||||
if ((i * j > ans) && ispalindrome(i * j))
|
||||
ans = i * j
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ function Problem5()
|
||||
What is the smallest positive number that is evenly divisible by all of
|
||||
the numbers from 1 to 20? =#
|
||||
ans = 1
|
||||
for i in 1:21
|
||||
for i = 1:21
|
||||
ans *= i ÷ gcd(i, ans)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user