

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
In this article, we will learn about the solution and approach to solve the given problem statement.
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 −
Example
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")
Output
No
All variables and functions are declared in global scope as shown in the figure below.
Conclusion
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.
- 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++
- Number of digits to be removed to make a number divisible by 3 in C++
- Check whether it is possible to make both arrays equal by modifying a single element in Python
- Check whether product of digits at even places of a number is divisible by K in Python
- Check whether sum of digits at odd places of a number is divisible by K in Python
- 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
- C Program to Check if all digits of a number divide it
- PHP program to check if all digits of a number divide it
- Java Program to 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