persian-numbers

command module
v0.0.0-...-817ff49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 2 Imported by: 0

README

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

  1. Clone the repository:
git clone https://codeberg.org/PinkOrca/persian-numbers.git
  1. Navigate to the project directory:
cd persian-numbers
  1. Build the program:
go build
  1. Run the executable:
./persian-numbers
  1. 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:

  1. convertThreeDigits(number int): This function takes a three-digit number and converts it to its Persian word representation.

  2. 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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL