Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- # Some magic shit I found online
- def primes(n):
- primfac = []
- d = 2
- while d*d <= n:
- while (n % d) == 0:
- primfac.append(d) # supposing you want multiple factors repeated
- n //= d
- d += 1
- if n > 1:
- primfac.append(n)
- counted = Counter(primfac)
- return counted
- # Factor the number you want
- prime_factorisation = primes(420)
- # Generate the squares and stuff
- arr = []
- for i in prime_factorisation:
- arr.append(i**prime_factorisation[i])
- # Transpose, flip upside down and print the array
- for i in range(max(arr) - 1, -1, -1):
- for j in range(len(arr)):
- if arr[j] > i:
- print ('#', end='')
- else:
- print (' ', end='')
- print ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement