Prime Palette

A postcard of a figure created by Sondra Eklund depicting the prime factorizations of the first 100 integers. [Image courtesy of Steven Strogatz and Sondra Eklund via Twitter.]

Identifying and storing prime factors

def prime_factors(number):
""" Returns a list of prime factors of an input number. """

prime_factors = []
x = 333
dividend = number
divisor = 2

while x == 333:
if dividend == 1:
return prime_factors
if dividend % divisor == 0:
dividend = dividend/divisor
divisor += 1
def prime_df(number):
""" Returns a list of prime factors of a range of numbers from 2
to the input number. """
num_prime_array = np.array(([2, 2, 1]))if number > 2:
for this_num in range(3, number+1):
num_primes = prime_factors(this_num)

#saving out numbers' unique primes and their counts
if this_num > 1:
unique, counts = np.unique(num_primes,
freq = np.asarray((list(unique), list(counts))).T
num_id = np.array([[this_num] * len(freq)]).T
num_id_unique_counts = np.hstack((num_id, freq))
num_prime_array = np.vstack((num_prime_array,
num_prime_df = pd.DataFrame(num_prime_array)
num_prime_df = pd.DataFrame([num_prime_array], index=[0])

num_prime_df.columns = ['Numbers', 'Primes', 'Powers']
return num_prime_df

Depicting prime factors

cmap = sns.blend_palette([color_1,color_2],n_colors=max(num_prime_df.Powers))




I’m a data scientist with neuroscientific roots. Learn more about me here:

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Atlassian… are you serious?!

How to Deploy a Firewall in front of a Network

Revomon — Eggomon feature + airdrop🥚

DevOps Monolith

Jenkins-X with Tekton pipelines on kubernetes

Beautiful Soup template and example for Python web scraping

Blockchain Series — Getting Started with MetaMask

GraphQL Server With Java & Clients in Go and Rust

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Athula Pudhiyidath

Athula Pudhiyidath

I’m a data scientist with neuroscientific roots. Learn more about me here:

More from Medium

Scheduling Python scripts through Windows Task Scheduler

Introduction to Python(Part-2): Python Installation

Python NumPy Library Tutorial Part : 1

The helicopter view of Python (for intermediate) part 1