Site icon T4Tutorials.com

The sum of two prime numbers is 85. what is the product of these two prime numbers?

The sum of two prime numbers is 85. what is the product of these two prime numbers?

X = Suppose X is a prime number.

Y = Suppose Y is a prime number.

X+Y = 85

First See: 1 and 84: 1 is, not a prime number, 84 is not a prime number.

Now See 2 and 83: both numbers are prime numbers.

All even numbers are paired with a possible odd prime number,  therefore both won’t be prime numbers because the only even prime number is 2.

Similarly, If we count back, All evens from 80 then these are paired with possible odd primes numbers, however, the even numbers can’t be be considered as prime numbers.

The one and only one possible solution is the pair of two numbers and the numbers are 2 and 83 and the product of 2 and 83 is 166.

Let’s explain it some other helping material of prime numbers.

List of prime numbers

All prime numbers are illustrated with pink color circles.

Sum of Prime number with classes

Let’s see a little demo with the C++ program that works on sum of prime numbers.

#include<iostream>
using namespace std;
class T4Tutorials
{
	protected :
		int n, i, flg1,flg2,flg3,j;
	public :
		int checK()
		{
			flg1=1,flg2=1,flg3=0;
			cout<<"Input  a positive integer: ";
			cin>>n;
			  for(i=3; i<=n/2; i++)
		     {     
		      flg1=1;
		      flg2=1;
		      for(j=2; j<i; j++)
		       {     
		         if(i%j==0)
		           { flg1=0;j=i;}
		        }
		      for(j=2; j<n-i; j++)
		       {     
		         if((n-i)%j==0)
		           { flg2=0;j=n-i;}
		        }
		         if(flg1==1 && flg2==1)
		           { printf("%d =  %d + %d  \n",n,i,n-i); 
		           flg3=1;}
		    }
         if(flg3==0)
           {printf("\n%d can not be expressed as sum of two prime numbers.\n\n",n);}
		}
};
int main()
{
	T4Tutorials a;
	a.checK();
}

 

C++  program to Check Whether a Number can be Express as Sum of Two Prime Numbers by using the single inheritance.

#include<iostream>
using namespace std;
class T4Tutorials
{
	protected :
		int  n, i;
};
class T4Tutorials_child
{
	protected :
		int n, i, X,Y,Z,j;
	public :
		int checK()
		{
			X=1,Y=1,Z=0;
			cout<<"\n\nCheck Whether a Number can be Express as Sum of Two Prime Numbers:\n ";
			cout<<"Input  a positive integer: ";
			cin>>n;
			  for(i=3; i<=n/2; i++)
		     {     
		      X=1;
		      Y=1;
		      for(j=2; j<i; j++)
		       {     
		         if(i%j==0)
		           { X=0;j=i;}
		        }
		      for(j=2; j<n-i; j++)
		       {     
		         if((n-i)%j==0)
		           { Y=0;j=n-i;}
		        }
		         if(X==1 && Y==1)
		           { printf("%d =  %d + %d  \n",n,i,n-i); 
		           Z=1;}
		    }
         if(Z==0)
           {printf("\n%d can not be expressed as sum of two prime numbers.\n\n",n);}
		}
};
int main()
{
	T4Tutorials_child a;
	a.checK();
}

C++  program to Check Whether a Number can be Express as Sum of Two Prime Numbers by using the multiple inheritances.

#include<iostream>
using namespace std;
class T4Tutorials1
{
	protected :
		int  n, i;
};
class T4Tutorials2
{
	protected :
		int flg3,j;
};
class T4Tutorials3 : public T4Tutorials2 , public T4Tutorials1
{
	protected :
		int  flg1,flg2,flg3,j;
	public :
		int checK()
		{
			flg1=1,flg2=1,flg3=0;
			cout<<"\n\nCheck Whether a Number can be Express as Sum of Two Prime Numbers:\n ";
			cout<<"Input  a positive integer: ";
			cin>>n;
			  for(i=3; i<=n/2; i++)
		     {     
				/*---------- check for prime---------------*/
		      flg1=1;
		      flg2=1;
		      for(j=2; j<i; j++)
		       {     
		         if(i%j==0)
		           { flg1=0;j=i;}
		        }
		      for(j=2; j<n-i; j++)
		       {     
		         if((n-i)%j==0)
		           { flg2=0;j=n-i;}
		        }
		         if(flg1==1 && flg2==1)
		           { printf("%d =  %d + %d  \n",n,i,n-i); 
		           flg3=1;}
		    }
         if(flg3==0)
           {printf("\n%d can not be expressed as sum of two prime numbers.\n\n",n);}
		}
};
int main()
{
	T4Tutorials3 a;
	a.checK();
}

C++  program to Check Whether a Number can be Express as Sum of Two Prime Numbers by using the multi-level inheritance.

#include<iostream>
using namespace std;
class T4Tutorials_grandFather
{
	protected :
		int  n, i;
};
class T4Tutorials_Father : public T4Tutorials_grandFather
{
	protected :
		int flg3,j;
};
class T4Tutorials3 : public T4Tutorials_Father 
{
	protected :
		int  flg1,flg2,flg3,j;
	public :
		int checK()
		{
			flg1=1,flg2=1,flg3=0;
			cout<<"\n\nCheck Whether a Number can be Express as Sum of Two Prime Numbers:\n ";
			cout<<"Input  a positive integer: ";
			cin>>n;
			  for(i=3; i<=n/2; i++)
		     {     
				/*---------- check for prime---------------*/
		      flg1=1;
		      flg2=1;
		      for(j=2; j<i; j++)
		       {     
		         if(i%j==0)
		           { flg1=0;j=i;}
		        }
		      for(j=2; j<n-i; j++)
		       {     
		         if((n-i)%j==0)
		           { flg2=0;j=n-i;}
		        }
		         if(flg1==1 && flg2==1)
		           { printf("%d =  %d + %d  \n",n,i,n-i); 
		           flg3=1;}
		    }
         if(flg3==0)
           {printf("\n%d can not be expressed as sum of two prime numbers.\n\n",n);}
		}
};
int main()
{
	T4Tutorials3 a;
	a.checK();
}

Hopefully, now if someone asks you that the sum of two prime numbers is 85, then you can easily calculate the product of 85.

 

Exit mobile version