Click the Twitter icon to follow our tweets and
know more about us.

Using recursion find product of digits

class pro_dig
{
   public static void main(int n)
   {
       int product=prodig(n);
       System.out.println(product);
    }
    public static int prodig(int n)
    {   int s=1;
        if(n==0)
        return 1;
        else
        {
            s=s*n%10;
            s=s*prodig(n/10);
            return s;
        }
    }
}

Comments (1)

does not compile correctly on NetBeans...

Post a Comment