A super-d number is a positive, decimal (base ten) integer   n   such that   d × nd   has at least   d   consecutive digits   d   where

   2 ≤ d ≤ 9

For instance, 753 is a super-3 number because 3 × 7533 = 1280873331.


Super-d   numbers are also shown on   MathWorld™   as   super-d    or   super-d.



Task

 Write a function/procedure/routine to find super-d numbers.
 For   d=2   through   d=6,   use the routine to show the first   10   super-d numbers.


Extra credit

 Show the first   10   super-7, super-8, and/or super-9 numbers   (optional).


See also

   Wolfram MathWorld - Super-d Number.
   OEIS: A014569 - Super-3 Numbers.


 
import java.math.BigInteger;
 
public class SuperDNumbers {
 
    public static void main(String[] args) {
        for ( int i = 2 ; i <= 9 ; i++ ) {
            superD(i, 10);
        }
    }
 
    private static final void superD(int d, int max) {
        long start = System.currentTimeMillis();
        String test = "";
        for ( int i = 0 ; i < d ; i++ ) {
            test += (""+d);
        }
 
        int n = 0;
        int i = 0;
        System.out.printf("First %d super-%d numbers: %n", max, d);
        while ( n < max ) {
            i++;
            BigInteger val = BigInteger.valueOf(d).multiply(BigInteger.valueOf(i).pow(d));
            if ( val.toString().contains(test) ) {
                n++;
                System.out.printf("%d ", i);
            }
        }
        long end = System.currentTimeMillis();
        System.out.printf("%nRun time %d ms%n%n", end-start);
 
    }
 
}
 