# Prime Factorization π’
This simple Python script takes a number from the user and returns its prime factors.
## π Project Description
The goal of this project is to take a single integer input and break it down into its prime components β if any.
For example, 60
becomes \[2, 2, 3, 5]
.
The script uses a basic loop and modulo division to determine whether a number is divisible by an incrementing divisor, starting from 2. Every time it finds a divisor, it divides the original number by it and stores it in a list.
## π‘ What You'll Learn
- Basic number theory (prime factorization)
- Using while
loops and conditionals
- The try
/except
/finally
block for input validation
- Working with integer division (//
) in Python
- Building and printing a list of results
## π Example
Give a number: 39999
Prime factors are: [3, 67, 199]
## π§ How It Works
1. The program starts with the smallest prime (2).
2. It checks if the number is divisible by the current divisor.
3. If yes, it adds the divisor to a list and divides the number.
4. If not, it moves to the next integer.
5. The loop continues until the number is reduced to 1.
## π Files Included
- prime\_factorization.ipynb
β Jupyter Notebook with the working code
- README.md
β this file
In addition to the standard prime factorization, this project includes an interactive mode.
After each found prime factor, the program asks the user whether to continue or stop.
This allows the user to step through the factorization process one factor at a time.
Give a number: 60 Do you want to continue? yes Actual prime list is: [2] Do you want to continue? yes Actual prime list is: [2, 2] Do you want to continue? no Prime factors are: [2, 2]
Created with π» by Olga KΔska