Thursday 27 August 2020

Find Digits Hacker Rank solution in C

 https://www.hackerrank.com/challenges/find-digits/problem


#include <stdio.h>
int main()
{
    unsigned long long int t;
    scanf("%llu",&t);
    while(t--)
    {
        unsigned long long int n,c=0,temp;
        scanf("%llu",&n);
        temp=n;
        while(n>0)
        {
            int digit=(n%10);
            if(digit > 0)
                if(temp%digit == 0)
                    c++;
            n=n/10;
        }
        printf("%llu\n",c);
    }
}

No comments:

Post a Comment