UVA Problem 10490 ( Mr. Azad and his Son) Solution

Problem Solving, UVa

#include<iostream>

#include<cstdio>

#include<cmath>

using namespace std;



int main()

{

    int n;

    int prime[] = {2,3,5,7,11,13,17,19,23,29,31};

    int sum,i,j,count;

    while(scanf("%d",&n)==1)

    {

        if(n==0)

            break;

        count =0;

        for(i=0; i<11; i++)

        {

            if(n==prime[i])

                count =1;

        }

        if(count==1)

        {

            if(n==11 || n==23 || n==29)

            {

                cout<<"Given number is prime. But, NO perfect number is available." << endl;

            }

            else

            {

                sum = pow(2,n-1) * (pow (2,n)-1);

                cout << "Perfect: " << sum <<'!'<<endl;

            }

        }

        else

        {

            cout << "Given number is NOT prime! NO perfect number is available."<<endl;

        }

    }

return 0;

}

 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...