Java Saved Program: beautiful-city

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.Scanner.*;
public class Interview
{
long m,n;
int flag, numTest;

public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of test cases");
numTest = sc.nextInt();
if(numTest>10)
System.out.println("Invalid input");
else
{while(testNum!=0)
{
System.out.println("Enter m and n");
m = sc.nextLong();
n = sc.nextLong();
if(n>=1000000000 && (n-m)<=100000)
System.out.prinln("Invalid input");
else
{
for(;m<n;m++)
{
for(;m>0;m--)
{if(m%(m-1)!=0)
System.out.print(" " +m);
}
System.out.endl();
}
}
testNum--;
}
}
}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs