public static int smallest(int n)
    {
        int i = 1;
        for (; ; )
        {
            int contain = 0;
            int temp = 0;
            int myNum = 0;
            for (int j = 1; j <= n; j++)
            {
                myNum = i * j;
                temp = myNum;
                while (true)
                {
                    if (temp % 10 == 2)
                    {
                        contain++;
                        break;
                    }
                    temp = temp / 10;
                    if (temp <= 0)
                        break;
                }
            }
            if (contain == n)
                break;
            i++;
        }
        return i;
    }
solved Solving with only loop