ISC 2018 Practical: Gold Bach Number Program
A Gold Bach number is a positive even integer that can be expressed as the sum of two odd primes.Note: All even integer numbers greater than 4 are Gold Bach numbers.Example:6 = 3 + 310 = 3 + 710 = 5 + 5Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3, 7 and 5, 5
java videos
This program was asked in ISC 2018 Practical computer science paper. It a called Gold Bach number.
A Gold Bach number is a positive even integer that can be expressed as the sum of two odd primes.
Note: All even integer numbers greater than 4 are Gold Bach numbers.
Example:
6 = 3 + 3
10 = 3 + 7
10 = 5 + 5
Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3, 7 and 5, 5.
Write a program to accept an even integer ‘N’ where N > 9 and N < 50. Find all the odd prime pairs whose sum is equal to the number ‘N’.
Test your program with the following data and some random data:
Example 1:
INPUT:
N = 14
OUTPUT:
Prime pairs are:
3, 11
7, 7
Example 2:
INPUT:
N = 30
OUTPUT:
Prime numbers are:
7, 23
11, 19
13, 17
Example 3:
INPUT:
N = 17
OUTPUT:
Invalid input. Number is odd.
Example 4:
INPUT:
N = 126
OUTPUT:
Invalid input. Number is out of range.
import java.io.*;
class GoldBach
{
static int isPrime(int x)
{
int rem;
int count=0;
for(int i=1;i<=x;i++)
{
rem=x%i;
if(rem==0)
{
count++;
}
}
return count;
}
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter the number");
int N=Integer.parseInt(br.readLine());
int res1=0;
int res2=0;
if(N>9 && N<50)
{
if(N%2==0)
{
System.out.println("PRIME PAIRS ARE:");
for(int i=3;i<=N;i++)
{
if(i%2!=0)
{
res1=isPrime(i);
for(int j=i;j<=N;j++)
{
if(j%2!=0)
{
res2=isPrime(j);
if(res1==2&&res2==2)
{
int temp=i+j;
if(temp==N)
{
System.out.println(i+", "+j); }
}
res2=0;
}
}
res1=0;
}
}
}
else
{
System.out.println("INVALID INPUT. NUMBER IS ODD"); }
}
else
{
System.out.println("INVALID INPUT. NUMBER OUT OF RANGE."); }
}
}Output:
Enter the number
14
PRIME PAIRS ARE:
3, 11
7, 7
java programs
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.