Computer Science, asked by MADANLAL4364, 11 months ago

Write a program to check whether a number is unique or not

Answers

Answered by kamal1423
2
I can write in python if you have to check whether the no is unique in a given list
Answered by Anonymous
3

import java.util.*;

class unique_number

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter a number to check whether it is unique number or not");

int n=sc.nextInt();

int cpy=n;

int d=0;

int c=0;

int flag=0;

for(int i=0;i<=9;i++)

{

n=cpy;

c=0;

while(n>0)

{

d=n%10;                

if(d==i)

{

   c++;

}

n=n/10;

}

if(c>1)

{

flag=1;

break;

}

}

if(flag==0)

{

System.out.println("Unique number");

}

else

{

System.out.println("Not a unique number");

}

}

}

Similar questions