Below is the source code for C Program to Find Number is Prime or Not using Recursion which is successfully compiled and run on Windows System to produce desired output as shown below :. If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.
We will try our best to reach up to you in the short interval. Thanks for reading the post…. If number of even, it in a prime only of 2. Else if below 7, it is a prime if not 1. Else to find a prime above 7, add 2 to previous prime candidate and recursively test if it is a prime.
Like OP's self description , in this case "And too lazy to tell anything further. You can try finding prime numbers between 1 and a given integer N list of prime numbers in a range using the below code :.
SOLUTION: Decrease the use of rec function under conditional statements by having a loop in main function to pass number under checking prime or not in rec function. Use Sieve of Eratosthenes fast, simple and interesting or some modified version fastest of it to print prime numbers to any extent very quickly. Also try to learn Sieve of Sundaram it is also slow but interesting and Sieve of Atkin fast and interesting but complex. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to find prime numbers in C using recursion Ask Question. Asked 6 years, 6 months ago. Active 4 years, 3 months ago. Ultimately, only prime numbers can perfectly divide any number. Take a pen and paper and give it a try. Your email address will not be published. Notify me of follow-up comments by email.
Notify me of new posts by email. Skip to content. More in Python Python Compiler. Java Core Java Tutorial. Java Type Conversion Examples. Java Wrapper Class. Java 8.
Java More in Java Java Compiler. Computer Sci. Computer Architecture. Computer Network. Database DBMS. Learn SQL.
0コメント