- Related Questions & Answers
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array?
- C/C++ Program to check whether it is possible to make the divisible by 3 number using all digits in an array?
- Possible to make a divisible by 3 number using all digits in an array in C++
- C Program to check if a number is divisible by sum of its digits
- C Program to check if a number is divisible by any of its digits
- Python Program for Check if all digits of a number divide it
- Python program to print all the numbers divisible by 3 and 5 for a given number
- Java Program to check if all digits of a number divide it
- C Program to Check if all digits of a number divide it
- PHP program to check if all digits of a number divide it
- C# Program to find whether the Number is Divisible by 2
- Check if a large number is divisible by 3 or not in java
- Check if a large number is divisible by 3 or not in C++
- How to find whether the Number is Divisible by 2 using C#?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution and approach to solve the given problem statement.

Given an array input of integers, we need to find whether it’s possible to make an integer using all the digits available in these numbers such that it would be divisible by 3.

Here we will generate a function that will take two arguments namely the array of integers and the length of the array.

The implementation given below works on the concept from the mental mathematics. Here we observe that a number is divisible by 3 if the sum of the digits are divisible by 3.

Now let’s see the implementation below −

def isPossibleToMakeDivisible(arr, n): remainder = 0 for i in range (0, n): remainder = (remainder + arr[i]) % 3 return (remainder == 0) # main() arr = [33,40,90] n = 3 if (isPossibleToMakeDivisible(arr, n)): print("Yes") else: print("No")

No

All variables and functions are declared in global scope as shown in the figure below.

In this article, we learnt about the approach to find whether it is possible to make a divisible by 3 number using all digits in an array.

Advertisements