Advertisement
Guest User

Stack Maker

a guest
Feb 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from collections import Counter
  2.  
  3. # Some magic shit I found online
  4. def primes(n):
  5.     primfac = []
  6.     d = 2
  7.     while d*d <= n:
  8.         while (n % d) == 0:
  9.             primfac.append(d)  # supposing you want multiple factors repeated
  10.             n //= d
  11.         d += 1
  12.     if n > 1:
  13.        primfac.append(n)
  14.  
  15.     counted = Counter(primfac)
  16.     return counted
  17.  
  18. # Factor the number you want
  19. prime_factorisation = primes(420)
  20.  
  21. # Generate the squares and stuff
  22. arr = []
  23. for i in prime_factorisation:
  24.     arr.append(i**prime_factorisation[i])
  25.  
  26. # Transpose, flip upside down and print the array
  27. for i in range(max(arr) - 1, -1, -1):
  28.     for j in range(len(arr)):
  29.         if arr[j] > i:
  30.             print ('#', end='')
  31.         else:
  32.             print (' ', end='')
  33.     print ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement