Computer Science, asked by singhprakashkumar271, 5 months ago

Shyam is very fond of numbers. He likes to call it the StrongNumber Game. The Game Goes as follow
You factorize a number it will have some prime Numbers and their powers Assume there are Kaver
Powers and P odd Powers.
A number is Strong Number if K>P else it is a weak number
Write a program to identify if a number is a strong number or a Weak Number
Example 745
Factors: 3*3*7*7 &5 = 3^2 * 7^2 5^1​

Answers

Answered by dreamrob
7

Program :

#include<iostream>

using namespace std;

int main()

{

int n , K = 0 , P = 0;

cout<<"Enter a number : ";

cin>>n;

for(int i = 2 ; i <= n ; i++)

{

 int x = 0;

 while(n % i == 0)

 {

  n = n / i;

  x++;

 }

 if(x % 2 == 0)

 {

  K++;

 }

 else

 {

  P++;

 }

}

if(K > P)

{

 cout<<"The number is a Strong Number";

}

else

{

 cout<<"The number is not a Strong Number";

}

      return 0;

}

Similar questions