File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ // see this to check other variations of fizzbuzz: https://www.geeksforgeeks.org/fizz-buzz-implementation/
2
+
3
+ vector<string> Solution::fizzBuzz (int A) {
4
+ vector<string> v;
5
+ for (int i=1 ; i<=A; i++)
6
+ {
7
+ if (i%15 ==0 )
8
+ v.push_back (" FizzBuzz" );
9
+ else if (i%3 ==0 )
10
+ v.push_back (" Fizz" );
11
+ else if (i%5 ==0 )
12
+ v.push_back (" Buzz" );
13
+ else
14
+ v.push_back (to_string (i));
15
+ }
16
+ return v;
17
+ }
Original file line number Diff line number Diff line change
1
+ // reference: https://www.geeksforgeeks.org/largest-number-divides-x-co-prime-y/
2
+ // Note: you can write the function for gcd [i'm using inbuilt gcd function in c++]
3
+
4
+ int Solution::cpFact (int x, int y) {
5
+
6
+ while (__gcd (x, y) != 1 ) {
7
+ x = x / __gcd (x, y);
8
+ }
9
+ return x;
10
+ }
You can’t perform that action at this time.
0 commit comments