• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 16, 2024 |150 Views
Write an Efficient Method to Check if a Number is Multiple of 3
  Share   Like
Description
Discussion

The very first solution that comes to our mind is the one that we learned in school. If the sum of digits in a number is a multiple of 3 then the number is a multiple of 3, e.g., for 612, the sum of digits is 9 so it’s a multiple of 3. But this solution is not efficient. You have to get all decimal digits one by one, add them and then check if the sum is a multiple of 3. Write an Efficient Method to Check if a Number is Multiple of 3 : https://www.geeksforgeeks.org/write-an-efficient-method-to-check-if-a-number-is-multiple-of-3/

Read More