This Python code counts the number of trailing zeros in an input number.
- Ensure you have Python installed on your system.
- Clone this repository or download the
count_zeros.py
file. - Open a terminal or command prompt and navigate to the directory where the
count_zeros.py
file is located. - Run the script by executing the following command:
python main.py
- Enter a number when prompted and press Enter.
- The program will calculate and display the number of trailing zeros in the input number.
Enter number: 1204000 Output: 3
The code takes a user input number and counts the number of trailing zeros by repeatedly dividing the number by 10 and checking if the remainder is 0. The count is incremented for each zero encountered until a non-zero digit is reached.
The code has been structured as a function, count_zeros()
, for reusability. The main part of the code prompts the user for input, calls the count_zeros()
function, and displays the result.
Contributions to this code are welcome. If you find any issues or have ideas for improvements, please open an issue or submit a pull request.