-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleet.java
More file actions
32 lines (28 loc) · 821 Bytes
/
leet.java
File metadata and controls
32 lines (28 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.*;
import java.lang.Math;
public class leet {
public static void main(String[] args) {
ArrayList<Integer> cars = new ArrayList<Integer>();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int b = n;
for (int i = n; i >= 1; i--) {
if (n > 0) {
int sr = (int) Math.sqrt(n);
// System.out.println(sr);
int a = sr * sr;
System.out.println(a);
if (a == n) {
cars.add(n);
n = b - n;
b = n;
n++;
}
}
n--;
}
System.out.println(cars);
sc.close();
}
}