Professional Documents
Culture Documents
Class Rickjit - Rickjit 11: Public Public Static New
Class Rickjit - Rickjit 11: Public Public Static New
import java.util.*;
public class Rickjit
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter m");
int m =sc.nextInt();
System.out.println("enter n");
int n =sc.nextInt();
long s1=0,s2=0,s3=0,sum=0,temp=0,nw=0;
int count=0;
String w="";
String s="";
if(m<99 || n>10000)
{
System.out.println("invalid input");
System.exit(0);
}
int c=0;
System.out.print( "fascinating no.s are : ");
for(int i=m;i<=n;i++)
{
s="";
s1=i*1;
s2=i*2;
s3=i*3;
s=s+s1+s2+s3;
nw=Long.parseLong(s);
sum=0;
while(nw>0)
{
temp=nw%10;
sum=sum+temp;
nw=nw/10;
}
boolean found=true;
for(char k = '1'; k <= '9'; k++)
{
count = 0;
for(int j = 0; j < s.length(); j++)
{
char ch = s.charAt(j);
if(ch == k)
count++;
}
if(count > 1 || count == 0)
{ found = false;
break;
}
}
}
System.out.println();
if(c > 00)
{
System.out.println("Total fascinating no.s are : "+c);
}
else
{
System.out.println("fascinating no.s are : nil");
System.out.println("freq : 0");
}
}
}