🤖
Julia で Project Euler #1「3と5の倍数」
function f001(n::Int64)
result = 0
for i in 1:(n - 1)
if (i % 3 == 0) || (i % 5 == 0)
result += i
end
end
return result
end
f001(10)
# 23
f001(1000)
# 233168
function f001(n::Int64)
result = 0
for i in 1:(n - 1)
if (i % 3 == 0) || (i % 5 == 0)
result += i
end
end
return result
end
f001(10)
# 23
f001(1000)
# 233168
Discussion