Persian Numbers
This is a simple Go program that converts numbers to their Persian word representation. It supports numbers up to the trillion range.
Usage
- Clone the repository:
git clone https://codeberg.org/PinkOrca/persian-numbers.git
- Navigate to the project directory:
cd persian-numbers
- Build the program:
go build
- Run the executable:
./persian-numbers
- Enter a number when prompted, and the program will output its Persian word representation.
Example
Enter a number: 12345
دوازده هزار و سیصد و چهل و پنج
How it Works
The program uses several maps to store the Persian words for digits, tens, teens, hundreds, and order words (e.g., thousand, million, billion). It then defines two main functions:
-
convertThreeDigits(number int)
: This function takes a three-digit number and converts it to its Persian word representation.
-
numberToWords(number int64)
: This function takes an arbitrary number and converts it to its Persian word representation by breaking it down into groups of three digits, converting each group using convertThreeDigits
, and combining the results with the appropriate order words.
The main
function prompts the user to enter a number, reads the input, and calls numberToWords
with the provided number. The result is then printed to the console.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
License
This project is licensed under the MIT License.