Skip to content

Instantly share code, notes, and snippets.

@necronet
Created Jul 13, 2020
Embed
What would you like to do?
Find the largest residual of 2 digits number that can be divided by the sum of itself
# Find the largest residual of 2 digits number that can be divided by the sum of itself
# maxres(ab/(a+b))
library(tidyr)
count <- 0
max_index <- 0
for( i in 10:99) {
digits <- as.integer(substring(i, seq(nchar(i)), seq(nchar(i))))
aplusb <- digits[1] + digits[2]
if (max_index < ( i %% aplusb)){
max_index <- ( i %% aplusb)
number <- i
}
}
print(max_index)
print(number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment