#Java 8, (削除) 126 (削除ここまで) 104 bytes
Java 8, (削除) 126 (削除ここまで) 104 bytes
n->{for(;n>9;n=new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))*n);return n;}
-22 bytes thanks to @OlivierGrégoire.
Explanation:
n->{ // Method with long as both parameter and return-type
for(;n>9; // Loop as long as the number contains more than 1 digit
n= // Replace the current number with:
new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))
// Remove the first largest digit from the number,
*n // and multiply this new number with the removed digit
); // End of loop
return n; // Return the result
} // End of method
#Java 8, (削除) 126 (削除ここまで) 104 bytes
n->{for(;n>9;n=new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))*n);return n;}
-22 bytes thanks to @OlivierGrégoire.
Explanation:
n->{ // Method with long as both parameter and return-type
for(;n>9; // Loop as long as the number contains more than 1 digit
n= // Replace the current number with:
new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))
// Remove the first largest digit from the number,
*n // and multiply this new number with the removed digit
); // End of loop
return n; // Return the result
} // End of method
Java 8, (削除) 126 (削除ここまで) 104 bytes
n->{for(;n>9;n=new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))*n);return n;}
-22 bytes thanks to @OlivierGrégoire.
Explanation:
n->{ // Method with long as both parameter and return-type
for(;n>9; // Loop as long as the number contains more than 1 digit
n= // Replace the current number with:
new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))
// Remove the first largest digit from the number,
*n // and multiply this new number with the removed digit
); // End of loop
return n; // Return the result
} // End of method
#Java 8, 126(削除) 126 (削除ここまで) 104 bytes
long c(long n)->{int m=0;forfor(int;n>9;n=new c:Long((n+"").getBytes())m=c-48>m?c-48:m;return n<10?n:creplaceFirst(m*new Long(n=(n+"").replaceFirstchars(m+"").max().getAsInt()-48)+"",""))*n);;return n;}
-22 bytes thanks to @OlivierGrégoire.
Explanation:
long c(long n)->{ // Method with long as both parameter and return-type
int m=0; // Max-digit, starting at 0
for(int c:(n+"").getBytes());n>9; // Loop over theas digitslong ofas the input
m=c-48>m? number contains more than 1 digit
n= // IfReplace the current digit is larger than the currentnumber maxwith:
new cLong((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))
// UseRemove the currentfirst largest digit asfrom newthe maxnumber,
: *n // Else:
m; and //multiply this new number Leavewith the maxremoved digit the same
); // End of loop (implicit / single-line body)
return n<10? // If the input is a single digit:
n n; // Return this digit as result
: // Else:
c(m* // Recursive-call with this max digit, multiplied by
new Long((n+"").replaceFirst(m+"","")));
// the input minus this first digitresult
} // End of method
#Java 8, 126 bytes
long c(long n){int m=0;for(int c:(n+"").getBytes())m=c-48>m?c-48:m;return n<10?n:c(m*new Long((n+"").replaceFirst(m+"","")));}
Explanation:
long c(long n){ // Method with long as both parameter and return-type
int m=0; // Max-digit, starting at 0
for(int c:(n+"").getBytes()) // Loop over the digits of the input
m=c-48>m? // If the current digit is larger than the current max:
c-48 // Use the current digit as new max
: // Else:
m; // Leave the max digit the same
// End of loop (implicit / single-line body)
return n<10? // If the input is a single digit:
n // Return this digit as result
: // Else:
c(m* // Recursive-call with this max digit, multiplied by
new Long((n+"").replaceFirst(m+"","")));
// the input minus this first digit
} // End of method
#Java 8, (削除) 126 (削除ここまで) 104 bytes
n->{for(;n>9;n=new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))*n);return n;}
-22 bytes thanks to @OlivierGrégoire.
Explanation:
n->{ // Method with long as both parameter and return-type
for(;n>9; // Loop as long as the number contains more than 1 digit
n= // Replace the current number with:
new Long((n+"").replaceFirst((n=(n+"").chars().max().getAsInt()-48)+"",""))
// Remove the first largest digit from the number,
*n // and multiply this new number with the removed digit
); // End of loop
return n; // Return the result
} // End of method
#Java 8, 126 bytes
long c(long n){int m=0;for(int c:(n+"").getBytes())m=c-48>m?c-48:m;return n<10?n:c(m*new Long((n+"").replaceFirst(m+"","")));}
Explanation:
long c(long n){ // Method with long as both parameter and return-type
int m=0; // Max-digit, starting at 0
for(int c:(n+"").getBytes()) // Loop over the digits of the input
m=c-48>m? // If the current digit is larger than the current max:
c-48 // Use the current digit as new max
: // Else:
m; // Leave the max digit the same
// End of loop (implicit / single-line body)
return n<10? // If the input is a single digit:
n // Return this digit as result
: // Else:
c(m* // Recursive-call with this max digit, multiplied by
new Long((n+"").replaceFirst(m+"","")));
// the input minus this first digit
} // End of method