Problem 13 on Project Euler asks us to sum 100 50-digit numbers and give the first 10 digits of the result. This is pretty easy. Note we are using R’s integer division operator %/%
to discard the remainder of the large summed integer and just gives us the first 10 digits of the result.
## Problem 13
problem13 <- function() {
nums <- scan("problem13.dat")
s <- sum(nums)
s %/% 10^(floor(log10(s))–9)
}