Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Create divisible.py #259

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions divisible.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Python 3 program to
# check the number is
# divisible by all
# digits are not.

# Function to check
# the divisibility
# of the number by
# its digit.
def checkDivisibility(n, digit) :

# If the digit divides the
# number then return true
# else return false.
return (digit != 0 and n % digit == 0)

# Function to check if
# all digits of n divide
# it or not
def allDigitsDivide( n) :

temp = n
while (temp > 0) :

# Taking the digit of
# the number into digit
# var.
digit = temp % 10
if ((checkDivisibility(n, digit)) == False) :
return False

temp = temp // 10

return True

# Driver function
n = 128

if (allDigitsDivide(n)) :
print("Yes")
else :
print("No" )

# This code is contributed by Nikita Tiwari.