crosby0486

Percentage of Units in the Set of Integers Mod n for n = 2 through 50

May 7th, 2021 (edited)
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. *The Code*
  2.  
  3. def units(n):
  4. u = []
  5. elem = list(range(1,n))
  6. o = 1
  7. while o < n:
  8. for x in elem:
  9. if (x * o) % n == 1:
  10. if o not in u:
  11. list.append(u,o)
  12. o += 1
  13. print("The Units for the Integers Mod ", str(n), " are: ", str(u))
  14.  
  15. b = "{:.0%}".format(len(u)/n)
  16.  
  17. print("The percentage of which is ", str(b))
  18.  
  19. a = list(range(2,51))
  20.  
  21. for x in a:
  22. units(x)
  23.  
  24. *********************************************************
  25.  
  26. *The Results*
  27.  
  28. The Units for the Integers Mod 2 are: [1]
  29. The percentage of which is 50%
  30. The Units for the Integers Mod 3 are: [1, 2]
  31. The percentage of which is 67%
  32. The Units for the Integers Mod 4 are: [1, 3]
  33. The percentage of which is 50%
  34. The Units for the Integers Mod 5 are: [1, 2, 3, 4]
  35. The percentage of which is 80%
  36. The Units for the Integers Mod 6 are: [1, 5]
  37. The percentage of which is 33%
  38. The Units for the Integers Mod 7 are: [1, 2, 3, 4, 5, 6]
  39. The percentage of which is 86%
  40. The Units for the Integers Mod 8 are: [1, 3, 5, 7]
  41. The percentage of which is 50%
  42. The Units for the Integers Mod 9 are: [1, 2, 4, 5, 7, 8]
  43. The percentage of which is 67%
  44. The Units for the Integers Mod 10 are: [1, 3, 7, 9]
  45. The percentage of which is 40%
  46. The Units for the Integers Mod 11 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  47. The percentage of which is 91%
  48. The Units for the Integers Mod 12 are: [1, 5, 7, 11]
  49. The percentage of which is 33%
  50. The Units for the Integers Mod 13 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  51. The percentage of which is 92%
  52. The Units for the Integers Mod 14 are: [1, 3, 5, 9, 11, 13]
  53. The percentage of which is 43%
  54. The Units for the Integers Mod 15 are: [1, 2, 4, 7, 8, 11, 13, 14]
  55. The percentage of which is 53%
  56. The Units for the Integers Mod 16 are: [1, 3, 5, 7, 9, 11, 13, 15]
  57. The percentage of which is 50%
  58. The Units for the Integers Mod 17 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
  59. The percentage of which is 94%
  60. The Units for the Integers Mod 18 are: [1, 5, 7, 11, 13, 17]
  61. The percentage of which is 33%
  62. The Units for the Integers Mod 19 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
  63. The percentage of which is 95%
  64. The Units for the Integers Mod 20 are: [1, 3, 7, 9, 11, 13, 17, 19]
  65. The percentage of which is 40%
  66. The Units for the Integers Mod 21 are: [1, 2, 4, 5, 8, 10, 11, 13, 16, 17, 19, 20]
  67. The percentage of which is 57%
  68. The Units for the Integers Mod 22 are: [1, 3, 5, 7, 9, 13, 15, 17, 19, 21]
  69. The percentage of which is 45%
  70. The Units for the Integers Mod 23 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
  71. The percentage of which is 96%
  72. The Units for the Integers Mod 24 are: [1, 5, 7, 11, 13, 17, 19, 23]
  73. The percentage of which is 33%
  74. The Units for the Integers Mod 25 are: [1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]
  75. The percentage of which is 80%
  76. The Units for the Integers Mod 26 are: [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]
  77. The percentage of which is 46%
  78. The Units for the Integers Mod 27 are: [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26]
  79. The percentage of which is 67%
  80. The Units for the Integers Mod 28 are: [1, 3, 5, 9, 11, 13, 15, 17, 19, 23, 25, 27]
  81. The percentage of which is 43%
  82. The Units for the Integers Mod 29 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
  83. The percentage of which is 97%
  84. The Units for the Integers Mod 30 are: [1, 7, 11, 13, 17, 19, 23, 29]
  85. The percentage of which is 27%
  86. The Units for the Integers Mod 31 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
  87. The percentage of which is 97%
  88. The Units for the Integers Mod 32 are: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
  89. The percentage of which is 50%
  90. The Units for the Integers Mod 33 are: [1, 2, 4, 5, 7, 8, 10, 13, 14, 16, 17, 19, 20, 23, 25, 26, 28, 29, 31, 32]
  91. The percentage of which is 61%
  92. The Units for the Integers Mod 34 are: [1, 3, 5, 7, 9, 11, 13, 15, 19, 21, 23, 25, 27, 29, 31, 33]
  93. The percentage of which is 47%
  94. The Units for the Integers Mod 35 are: [1, 2, 3, 4, 6, 8, 9, 11, 12, 13, 16, 17, 18, 19, 22, 23, 24, 26, 27, 29, 31, 32, 33, 34]
  95. The percentage of which is 69%
  96. The Units for the Integers Mod 36 are: [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35]
  97. The percentage of which is 33%
  98. The Units for the Integers Mod 37 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
  99. The percentage of which is 97%
  100. The Units for the Integers Mod 38 are: [1, 3, 5, 7, 9, 11, 13, 15, 17, 21, 23, 25, 27, 29, 31, 33, 35, 37]
  101. The percentage of which is 47%
  102. The Units for the Integers Mod 39 are: [1, 2, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 23, 25, 28, 29, 31, 32, 34, 35, 37, 38]
  103. The percentage of which is 62%
  104. The Units for the Integers Mod 40 are: [1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39]
  105. The percentage of which is 40%
  106. The Units for the Integers Mod 41 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
  107. The percentage of which is 98%
  108. The Units for the Integers Mod 42 are: [1, 5, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41]
  109. The percentage of which is 29%
  110. The Units for the Integers Mod 43 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42]
  111. The percentage of which is 98%
  112. The Units for the Integers Mod 44 are: [1, 3, 5, 7, 9, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 35, 37, 39, 41, 43]
  113. The percentage of which is 45%
  114. The Units for the Integers Mod 45 are: [1, 2, 4, 7, 8, 11, 13, 14, 16, 17, 19, 22, 23, 26, 28, 29, 31, 32, 34, 37, 38, 41, 43, 44]
  115. The percentage of which is 53%
  116. The Units for the Integers Mod 46 are: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]
  117. The percentage of which is 48%
  118. The Units for the Integers Mod 47 are: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]
  119. The percentage of which is 98%
  120. The Units for the Integers Mod 48 are: [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47]
  121. The percentage of which is 33%
  122. The Units for the Integers Mod 49 are: [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48]
  123. The percentage of which is 86%
  124. The Units for the Integers Mod 50 are: [1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49]
  125. The percentage of which is 40%
  126.  
Add Comment
Please, Sign In to add comment