Looping Problems
Looping Problems
import java.util.*;
class PerfectSquare{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long i= 1;
while(i*i<a){
i++;
}
if(i*i==a){
System.out.println("Perfect Squre");
}
else{
System.out.println("Not Perfect Square");
}
}
}
import java.util.Scanner;
3. Divide two give numbers & print the quotient value without using ( / ) operator.
import java.util.*;
class Main{
public static void main(String[] args ){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int res = 0;
System.out.println(sum);
}
}
if (flag == 1)
System.out.println("Triangular Number");
else
System.out.println("Not a Triangular Number");
}
}
7. Fibonacci Series accept an integer N and generate the First n terms of the
Fibonacci Series.
import java.util.Scanner;
System.out.print(first+" ");
System.out.print(second+ " ");
for (int i = 1; i <= n; i++) {
int next = first + second;
System.out.print(next + " ");
first = second;
second = next;
}
}
}