Created
July 13, 2020 04:05
-
-
Save necronet/3a36dc84eb8c50e833776e3f73668bf2 to your computer and use it in GitHub Desktop.
Find the largest residual of 2 digits number that can be divided by the sum of itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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