Skip to main content

Count Digits (DSA)

DSA 

Find the number of digits of ‘n’ that evenly divide ‘n’.

The objective is to calculate the modulus of each digit in the number n, then determine if that digit divides n. Consequently, increase the counter. Keep in mind that the digit may be 0, therefore handle such scenario.

int countDigits(int n){
    int count=0;
    for(int i=n; i>0; i=i/10)
    {
        int temp = i%10;
        if(temp>0 && n%temp==0)
         count++;
    }
     
    return count;
}


Comments

Popular posts from this blog

The Journey of Ram Mandir Ayodhya

  Introduction Welcome to this blog where we will explore the complete journey of the Ram Temple in Ayodhya, from its humble beginnings to its grand existence. Ayodhya holds a significant place in the religious and cultural tapestry of India, as it is believed to be the birthplace of Lord Ram, one of the most revered deities in Hinduism. The history of the Ram Temple is deeply intertwined with the socio-political landscape of India, with numerous debates and legal battles that have shaped its destiny. Let's delve into the rich history and significance of this sacred place. Ancient Origins According to Hindu mythology, Ayodhya is considered the birthplace of Lord Ram, the seventh avatar of Lord Vishnu. The ancient epic, Ramayana, narrates the story of Lord Ram's birth in Ayodhya and his journey to become a revered deity. The city of Ayodhya remained an important religious and cultural center throughout history, with various rulers and dynasties paying homage to Lord Ram and u...

Palindrome number (DSA)

Problem statement Check whether a given number   ’n’   is a palindrome number.   Example: Input: 'n' = 51415 Output: true Explanation: On reversing, 51415 gives 51415. Checking for Palindrome Numbers Palindrome numbers are numbers that read the same backward as forward. For example, 121 and 12321 are palindrome numbers. To check if a number is a palindrome, we can reverse the number and compare it with the original number. If they are the same, the number is a palindrome; otherwise, it is not. Using the concepts of extracting digits and reversing a number, we can efficiently check for palindrome numbers. bool  palindrome(int n) {      // Write your code here     int num= 0 ,temp;      for (int i=n; i> 0 ;i=i/ 10 )     {         temp=i% 10 ;         num=(num* 10 )+temp...

“Emerging AI: The Future of Technology Unveiled!”

  Today, we’re diving deep into the cutting-edge world of Artificial Intelligence — specifically, exploring the latest and most exciting developments in the field. Get ready to witness the wonders of Emerging AI as we unravel how it’s reshaping our world and what we can expect in the near future. If you’re as fascinated as I am about the potential of AI, don’t forget to hit that like button and subscribe, so you won’t miss any of our tech explorations. Let’s jump right in! AI-Powered Healthcare One of the most revolutionary applications of Emerging AI is in healthcare. From diagnosing diseases with unprecedented accuracy to assisting in surgeries, AI is transforming patient care. Imagine a world where AI-driven medical imaging can detect diseases at earlier stages, potentially saving countless lives. Today, we’ll witness some incredible AI-powered healthcare solutions that are making waves in the medical community. AI and Creative Industries AI’s capabilities are not limited to tec...