Skip to content

A simple C program to check if a number is prime and to generate prime numbers within a range or up to a given limit. Useful as an educational example of control flow, loops, functions, and basic number theory in C.

License

Notifications You must be signed in to change notification settings

Sandra1me/C-Prime-Number-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Prime Number Generator (C)

A simple C program to check if a number is prime and to generate prime numbers within a range or up to a given limit. Useful as an educational example of control flow, loops, functions, and basic number theory in C.

Features

  • Check if a number is prime
  • Generate all prime numbers up to a given limit
  • Find all prime numbers within a custom range
  • Simple terminal interface with user prompts

Compilation

To compile the program, use a C compiler like gcc:

gcc -o prime_generator prime_generator.c

Usage

Once compiled, run the program from the terminal:

./prime_generator

You will be prompted to choose one of the following options:

  1. Find prime numbers in a custom range
  2. Generate all prime numbers up to a given number
  3. Exit the program

Example

sample image

Contributing

Pull requests are welcome! If you have ideas for improvements (e.g. better UI, saving results to file, or performance optimizations), feel free to open an issue or fork the project.

License

This project is licensed under the MIT Licence.

About

A simple C program to check if a number is prime and to generate prime numbers within a range or up to a given limit. Useful as an educational example of control flow, loops, functions, and basic number theory in C.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages