Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:26+00:00 2026-06-17T12:35:26+00:00

Thats all in title. In simple i had write this. #include <iostream> using namespace

  • 0

Thats all in title.
In simple i had write this.

#include <iostream>
using namespace std;  
int main()  
{ 
    int a,i;  
    cout<<"Enter a number: ";  
    cin>>a;  
    for (i=2;i<=a/2;i++)  
    {  
        if (a%i==0)  
        {  
            cout<<"Its not Prime Number.";  
           system ("pause");  
            return 0;  
        }  
    }  
    cout<<"Its a Prime number.";  
    system ("pause");  
    }   

The main thing is WITHOUT using loop and with recursive function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:35:28+00:00Added an answer on June 17, 2026 at 12:35 pm

    Here’s a recursive primality test function:

    int test_prime(unsigned n, unsigned d)
    {
        if (n < 2) {
            return 0;
        }
    
        if (d == 1) {
            return 1;
        } else {
            if (n % d == 0) {
                return 0;
            } else {
                return test_prime(n, d - 1);
            }
        }
    }
    

    Use it like:

    unsigned n;
    std::cin >> n;
    std::cout << (test_prime(n, n / 2) ? "prime" : "not prime") << "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thats it really.. I am using VS2008 Express. All the samples say just to
Hey all, this is the code i have to check for a day thats
I'm having an issue with a simple PHP mailer. I've had this script working,
This is one of the hardest questions I've ever had to title here on
I had no idea to correctly form the title of this question, because I
I've had trouble finding an exact, and simple, answer to this question on SO
I know the title isn't informative at all, but I had no idea how
I have an NSDictionary that holds all the data: One title (not important for
First of all, sorry about that title. I'm not the best at writing those
I just have a question thats been pozzling my head all morning. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.