Advertisement
Programmin-in-Python

Python program to find the 10 digit number which satisfies the conditions given in the paste

Jan 18th, 2022
1,102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Conditions :-
  3. -------------
  4.  
  5. Find a 10 digit number whose,
  6. first digit is divisible by 1,
  7. first two digits are divisible by 2,
  8. first three digits are divisible by 3,
  9. .
  10. .
  11. .
  12. and so on, without any repetition of digits.
  13. """
  14.  
  15.  
  16.  
  17. from itertools import permutations as perm
  18.  
  19. L1 = perm([_ for _ in range(10)], 10)
  20.  
  21. for i in L1:
  22.     flag = True
  23.  
  24.     for ind, val in enumerate(i):
  25.         n = int("".join([str(i[_]) for _ in range(ind+1)]))
  26.  
  27.         if n%(ind+1):
  28.             flag = False
  29.             break
  30.     if flag:
  31.         print(n)
  32.  
  33. """        
  34. Output : 3816547290
  35. """
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement