13 lines
481 B
Text
13 lines
481 B
Text
fcn fangs(N){ //-->if Vampire number: (N,(a,b,c,...)), where a*x==N
|
|
var [const] tens=[0 .. 18].pump(List,(10.0).pow,"toInt");
|
|
|
|
(half:=N.numDigits) : if (_.isOdd) return(T);;
|
|
half/=2; digits:=N.toString().sort();
|
|
lo:=tens[half-1].max((N+tens[half])/(tens[half]));
|
|
hi:=(N/lo).min(N.toFloat().sqrt());
|
|
fs:=[lo .. hi].filter('wrap(n){
|
|
N%n==0 and (n%10!=0 or (N/n)%10!=0) and
|
|
(n.toString()+(N/n).toString()).sort()==digits
|
|
});
|
|
fs and T(N,fs) or T;
|
|
}
|