-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay38
63 lines (43 loc) · 1.18 KB
/
Day38
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
/* #Day38 of My #100DaysOfCodingChallenge: Exploring Bitmanipulation!
Problem Solved : Prime Factors
Problem Link : https://www.geeksforgeeks.org/problems/prime-factors5052/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=Prime-Factors
Problem Solved : Odd or Even
Problem Link : https://www.geeksforgeeks.org/problems/odd-or-even3618/1
*/
//Prime factors
class Solution {
public int[] AllPrimeFactors(int N) {
List<Integer> ans = new ArrayList<>();
for (int i = 2; i * i <= N; i++) {
if (N % i == 0) {
ans.add(i);
while (N % i == 0) {
N = N / i;
}
}
}
if (N != 1) {
ans.add(N);
}
// Convert List<Integer> to int[]
int[] result = new int[ans.size()];
for (int i = 0; i < ans.size(); i++) {
result[i] = ans.get(i);
}
return result;
}
}
//Odd even
class Solution {
static String oddEven(int n) {
// code here
if((n & 1) == 1)
{
return "odd";
}
else
{
return "even";
}
}
}