Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to find the range of composite numbers within two integers similar to sympy.primerange(a,b)

$
0
0

I was tinkering with the idea of the polar plotting of prime numbers and I'm currently using the code below to calculate and plot everything.

Unsure what detail to provide, so I'll provide all of it. I'm using JupyterLab from Anaconda and following everything nearly to a tea from this website.

I wanted to tinker around with the idea of plotting all composite numbers within a range instead of all prime numbers within a range, much like sympy.primerange does. There are few tools for composite numbers as opposed to prime numbers and I wanted to see if there was a workaround to this problem.

import mathimport sympyimport numpy as npimport matplotlib.pyplot as plt%matplotlib inline%config InlineBackend.figure_format='retina'plt.style.use('dark_background')

then

def get_coordinate(num):    return num * np.cos(num), num * np.sin(num)

and

def create_plot(nums, figsize=13.5, s=8, show_annot=True):    nums = np.array(list(nums))    x, y = get_coordinate(nums)    plt.figure(figsize=(figsize, figsize))    plt.axis("on")    plt.scatter(x, y, s=s)    plt.show()

then

primes = sympy.primerange(a, b)create_plot(primes)

I've tried sympy.composite but I consistently received errors and could not figure out how to make it a range. I've also attempted to copy-paste a database of composite numbers which was against the spirit of what I'm trying to do.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>