Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Find all plural integers, namely positive integers such that (a) none of their digits is zero and (b) removing their leftmost digit produces a dividing integer.

a slight modification in the R code allows for a faster exploration, based on the fact that solutions add one extra digit to solutions with one less digit:

First, I found this function on Stack Overflow to turn an integer into its digits:

pluri=plura=NULL
#solutions with two digits
for (i in 11:99){

dive=rev(digin(i)[-1])
if (min(dive)>0){
dive=sum(dive*10^(0:(length(dive)-1)))
if (i==((i%/%dive)*dive))
pluri=c(pluri,i)}}

for (n in 2:6){ #number of digits
plura=c(plura,pluri)
pluro=NULL
for (j in pluri){

for (k in (1:9)*10^n){
x=k+j
if (x==(x%/%j)*j)
pluro=c(pluro,x)}
}
pluri=pluro}


which leads to the same output

> sort(plura)
[1] 11 12 15 21 22 24 25 31 32 33 35 36
[13] 41 42 44 45 48 51 52 55 61 62 63 64
[25] 65 66 71 72 75 77 81 82 84 85 88 91
[37] 92 93 95 96 99 125 225 312 315 325 375 425
[49] 525 612 615 624 625 675 725 735 825 832 912
[61] 915 925 936 945 975 1125 2125 3125 3375 4125
[70] 5125 5625
[72] 6125 6375 7125 8125 9125 9225 9375 53125
[80] 91125 95625


Filed under: Books, Kids, R, Statistics, University life Tagged: arithmetics, Le Monde, mathematical puzzle, strsplit()