無聊的 R 版,是怕自己寫慣 Python 忘記了怎樣寫 R 。
#chew that < -
buyable <- function(numN) {
if (numN < 1) {return(NULL)}
else {rangefound <- as.integer((numN/6)+1)}
for (num6 in 0:rangefound) {
for (num9 in 0:rangefound) {
for (num20 in 0:rangefound) {
totalN <- 6*num6 + 9*num9 + 20*num20
if (totalN == numN) {
return(c(num6,num9,num20))
}
}
}
}
return(NULL)
}
unbuyable <- c()
for (trialnumN in 0:200) {
if (is.null(buyable(trialnumN))) {
unbuyable <- append(unbuyable, trialnumN)
}
}