This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
coding-corner/2017-04-11/ikselven_euler87.R

23 lines
441 B
R
Raw Normal View History

library(numbers)
MAX <- 5e7
primes <- Primes(1, ceiling(sqrt(MAX)))
potfilter <- function(numbers, filter)
numbers[numbers < filter]
sums <- sapply(
potfilter(primes^4, MAX),
function(x) {
sapply(
potfilter(primes^3, MAX),
function(y) {
sapply(primes^2, function(z) {
x+y+z
})
}
)
}
)
length(unique(sums[sums<MAX]))