Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def divisibility(b,d):
- type2, type3, type6, type7, type11 = (False,)*5
- num, no_to_digits = 0, 0
- if b == 2:
- num = bin(d)
- elif b == 8:
- num = oct(d)
- elif b == 16:
- num = hex(d)
- else:
- finalNum = int(str(d),b)
- if isinstance(num, str):
- finalNum = int(num[2:])
- if (finalNum%2 == 0) or (finalNum%4 == 0) or (finalNum%5 == 0) or (finalNum%8 == 0) or (finalNum%10 == 0):
- type2 = True
- if (finalNum%2 == 0) or (finalNum%5 == 0) or (finalNum%10 == 0):
- no_to_digits = 1
- elif (finalNum%4 == 0):
- no_to_digits = 2
- elif (finalNum%8 == 0):
- no_to_digits = 3
- if (finalNum%3 == 0) or (finalNum%9 == 0):
- type3 = True
- if (finalNum%11 == 0):
- type11 = True
- if (finalNum%6 == 0):
- type6 = True
- if (finalNum%7 == 0):
- type7 = True
- if type2:
- return f"2-type\n{no_to_digits}"
- elif type3:
- return "3-type"
- elif type6:
- return "6-type"
- elif type7:
- return "7-type"
- elif type11:
- return "11-type"
- var = divisibility(2,3)
- print(var)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement