Below are the results of the number of permutations for number 2313 and 7612. Any number with any amount of integers will also work. 3rd image is the permutations for number 8879829.
from math import factorial
#User input number for permutation calculation
myNum = input( ' Enter the number for permutation calculation.... ')
#change myNum which is a string, to myList
#which is an integer.
myList = list (map( int, myNum) )
lastIndex= len( myList ) - 1
#list to store integers to prevent repeated scanning
myList2 = [ ]
#list to store number of repeats for each integer
numberOfRepeats = [ ]
#function to check for repeated integer
def checkForRepeat ( num ):
isItRepeat = False
for i in myList2:
if i == num:
isItRepeat = True
return isItRepeat
#function to calculate the number
#of permutatiions
def calPermutation(repeatedNum):
fact = 1
for num in repeatedNum:
fact = fact * factorial( num )
return fact
#Loop to check for same integer.
for num1 in range ( 0 , lastIndex ):
sameNumCount = 1
#fn call to check for repeated int.
r = checkForRepeat( myList[num1] )
if r == True:
continue
myList2.append(myList[ num1 ])
for num2 in range ( num1+1, lastIndex +1):
if myList [ num1 ]== myList [ num2 ] :
sameNumCount = sameNumCount + 1
if sameNumCount > 1:
print(f'Number {myList[num1]} is repeated {sameNumCount} times')
numberOfRepeats.append ( sameNumCount)
#finally compute the number of permutations
divisor = calPermutation( numberOfRepeats)
permutations = int(factorial( len(myList) ) / divisor)
print (f'Number of permutations for {myNum} is {permutations}')



Code explanation:
There are 2 variables, 3 lists and 2 functions.
2 variables:
myNum: store the user input as string. sameNumCount: store the number of times an integer repeats.
3 lists: myList: store the list of integers which is converted from myNum(which is a string). myList2: use to store the integer after comparision so that the next same integer will not perform comparision again. numberOfRepeats: store the number of repeats of each integer. This list is use as a argument for calPermutation function.
2 functions: checkForRepeat: to check if an integer is repeated. If yes, the function will return True. Therefore the program will not scan the integer for comparision. calPermutation: to calculate the permutations of the number, after knowing how many integers is repeated and repeat how many times.