forked from junaidrahim/Hacktoberfest-KIIT-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lucky Number
42 lines (32 loc) · 824 Bytes
/
Lucky Number
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
33
34
35
36
37
38
39
40
41
42
import java.util.*;
import java.io.*;
import java.lang.*;
class Driver
{
public static void main(String args[])throws IOException
{
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(read.readLine());
while(t-- > 0)
{
int n = Integer.parseInt(read.readLine());
System.out.println((new Solution().isLucky(n))? "1" : "0");
new Solution().counter = 2;
}
}
}
class Solution
{
static int counter = 2;
public static boolean isLucky(int n)
{
int p=n/counter;
if(n%counter==0)
return false;
else if(n<counter)
return true;
else
counter++;
return isLucky(n-p);
}
}