-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterview.cs
More file actions
64 lines (46 loc) · 1.16 KB
/
interview.cs
File metadata and controls
64 lines (46 loc) · 1.16 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
public class HelloWorld
{
static public void MainC()
{
string prime_factor = Console.ReadLine();
int P = Convert.ToInt32(prime_factor);
string line = Console.ReadLine();
int T = Convert.ToInt32(line);
for (int t_i = 0; t_i < T; t_i++)
{
line = Console.ReadLine();
int n = Convert.ToInt32(line);
String out_ = check_special(n, P);
Console.WriteLine(out_);
}
}
static String check_special(int n, int p)
{
// This function returns YES if the given number is special number , NO
// otherwise
double N =n;
int count =0;
while (N % 2 == 0)
{
N /= 2;
}
int sqrRoot = (int)Math.Ceiling(Math.Sqrt(N));
for (int i = 3; i <= sqrRoot; i += 2)
{
while (N % i == 0)
{
N /= i;
}
/// if (N > 2)
}
if (N > 2)
{
return "YES";
}
return "NO";
}
}