FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
Twin Prime calculate the power of the given number in Java
CO Prime - Java
14927    Arnab De    13/12/2018

Accept two no from the user and write a program in Java to check that those numbers are co- prime or not.

If any two given number has no common factor except 1 then that pair of the numbers known as co-prime. The co-prime numbers are may or may not be a prime number themself.

Let two numbers are 14 and 15.

The factors of 14 are 1, 2, 7, 14 and the factors of 15 are 1, 3, 5, 15 the common factor is 1. Therefore, 14 and 15 are the pair of co-prime. In others words, if the HCF of two numbers is 1 then, that pair of numbers are called co-prime. Co-prime numbers are also known as a relatively prime or mutually prime.

```import java.util.*;

public class CoPrime
{
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first no");
int no1=sc.nextInt();
System.out.println("Enter the second no");
int no2=sc.nextInt();
int temp;
if(no2>no1)
{
temp=no2;
no2=no1;
no1=temp;
}
int r=-1;
while(r!=0)
{
r=no1%no2;
no1=no2;
no2=r;
}
if(no1==1)
{
System.out.println("CO Prime Number");
}
else
{
System.out.println("Not a CO Prime Number");
}
}
}

```
Twin Prime calculate the power of the given number in Java
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Education is the most powerful weapon which you can use to change the world.
Nelson Mandela
26182
52.75
Today So Far
Total View (Lakh)
26/05/2018     42031
01/01/2018     36003
28/06/2017     34089
25/06/2018     33447
02/08/2017     32401
01/08/2017     26864
06/07/2017     26791
15/05/2017     26418
14/07/2017     21855
21/04/2018     20717