Solution to problem 16 in Julia
This commit is contained in:
parent
e43b2a981a
commit
7f6ea29f1a
26
src/Julia/Problem016.jl
Normal file
26
src/Julia/Problem016.jl
Normal file
@ -0,0 +1,26 @@
|
||||
using Base: Integer
|
||||
#=
|
||||
Created on 26 Jul 2021
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for Problem 16 of Project Euler
|
||||
https://projecteuler.net/problem=16
|
||||
=#
|
||||
|
||||
function Problem16()
|
||||
#=
|
||||
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
|
||||
|
||||
What is the sum of the digits of the number 2^1000?
|
||||
=#
|
||||
n = 1000
|
||||
return sum(parse(Int, d) for d in string(2^BigInt(n)))
|
||||
end
|
||||
|
||||
|
||||
println("Time to evaluate Problem 16:")
|
||||
@time Problem16()
|
||||
println("")
|
||||
println("Result for Problem 16: ", Problem16())
|
Loading…
x
Reference in New Issue
Block a user