Prime Counting Function Visualizer
A Python program that visualizes the prime counting function π(x), which counts the number of prime numbers less than or equal to x.
Description
This project generates a step function graph showing how the count of prime numbers increases across a given range. The visualization helps understand the distribution of prime numbers, which is related to the famous Riemann Hypothesis in mathematics.
Features
- Generate prime numbers within any specified range
- Count cumulative primes up to each value
- Visualize the prime counting function as a step graph
- Clean, well-documented code with detailed function descriptions
Requirements
- Python 3.x
- matplotlib
Installation
-
Clone this repository: git clone https://github.com/AkashGoswamy/python-archive.git cd python-archive
-
Install required dependencies: pip install matplotlib
Usage
Run the program: python zeta.py
You'll be prompted to enter:
- Starting value of the range
- Ending value of the range
The program will then display a graph showing the prime counting function for your specified range.
Example
Enter Starting Value : 1 Enter End Value : 100
This will generate a step graph showing how many primes exist up to each number from 1 to 100.
How It Works
- generate_range() - Creates a list of consecutive integers
- generate_primes() - Finds all prime numbers in the range using trial division
- count_primes() - Counts cumulative primes at each point
- main() - Orchestrates the program and creates the visualization
Mathematical Background
The prime counting function π(x) is fundamental in number theory and is closely related to the Riemann Zeta function. It represents the number of primes less than or equal to x and exhibits interesting patterns that mathematicians have studied for centuries.
Author
Akash Goswamy
License
This project is open source and available for educational purposes.