C++ Beginner Questions
So i have 2 questions that need to be answered and i'm still currently stuck.
1. Given integer N, decide if it is possible to represent it as a sum of two squares of integers.
Definition
Method: IsSumOf2Squares
Parameter: unsigned int
Returns: bool
Method Signature: boolIsSumOf2Squares(unsignedintN)
Examples
1. 10
Returns True
10 = 1^2 + 3^2
2. 2
Returns True
2 = 1^2 + 1^2
3. 16
Returns True
16 = 0^2 + 4^2
2. You are given an integer N. Find the digits in this number that exactly divide N (division that leaves
0 as remainder) and display their count. For N=24, there are 2 digits (2 & 4). Both of these digits
exactly divide 24. So our answer is 2.
Note: If the same number is repeated twice at different positions, it should be counted twice,
e.g., For N=122, 2 divides 122 exactly and occurs at ones' and tens' position. So for this
case, our answer is 3. Division by 0 is undefined and will not be counted.
Definition
Method: DivideExactly
Parameter: unsigned int
Returns: unsigned int
Method Signature: unsigned intDivideExactly(unsignedintN)
Examples
1. 24
Returns 2
2 and 4 divides 24 equally.
2. 122
Returns 3
1 and 2 divides 122 equally.
3. 1024
Returns 3
1, 2 and 4 divides 1024 equally, 0 is not counted.
4. 345
Returns 2
3 and 5 divides 345 equally.
ANY help is appreciated and need this ASAP