Skip to main content
added 25 characters in body
Source Link
JAD
  • 3k
  • 1
  • 11
  • 31

R, 124124 112 bytes

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numericdouble(substringel(x,1:strsplit(n<-logc(x,10)+1""),1:n"")))};x}

Fails at N=45 because R insists on writing 10.000 as 1e+05, which isnt appreciated by as.numeric(), this is fixable by using as.integer() at the cost of 12 bytes:

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numericdouble(substringel(strsplit(c(as.integer(x),1:(n<-log(x,10)+1""),1:n"")))};x}

As a statistical programming language R has annoyingly wordy ways of splitting numbers into a vector of digits. Especially because everything has to be converted back from strings to numerical values explicitly.

12 bytes saved thanks to billywob.

R, 124 bytes

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numeric(substring(x,1:(n<-log(x,10)+1),1:n))};x}

Fails at N=45 because R insists on writing 10.000 as 1e+05, which isnt appreciated by as.numeric(), this is fixable by using as.integer() at the cost of 12 bytes:

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numeric(substring(as.integer(x),1:(n<-log(x,10)+1),1:n))};x}

As a statistical programming language R has annoyingly wordy ways of splitting numbers into a vector of digits. Especially because everything has to be converted back from strings to numerical values explicitly.

R, 124 112 bytes

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.double(el(strsplit(c(x,""),"")))};x}

Fails at N=45 because R insists on writing 10.000 as 1e+05, which isnt appreciated by as.numeric(), this is fixable by using as.integer() at the cost of 12 bytes:

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.double(el(strsplit(c(as.integer(x),""),"")))};x}

As a statistical programming language R has annoyingly wordy ways of splitting numbers into a vector of digits. Especially because everything has to be converted back from strings to numerical values explicitly.

12 bytes saved thanks to billywob.

Source Link
JAD
  • 3k
  • 1
  • 11
  • 31

R, 124 bytes

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numeric(substring(x,1:(n<-log(x,10)+1),1:n))};x}

Fails at N=45 because R insists on writing 10.000 as 1e+05, which isnt appreciated by as.numeric(), this is fixable by using as.integer() at the cost of 12 bytes:

f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.numeric(substring(as.integer(x),1:(n<-log(x,10)+1),1:n))};x}

As a statistical programming language R has annoyingly wordy ways of splitting numbers into a vector of digits. Especially because everything has to be converted back from strings to numerical values explicitly.