Homework 4 Problem 5
You cannot submit for this problem because the homework's deadline is due.
Description
In this question, we will check the property of the number.
Input and Output
The program will take two int numbers as input, the first one refers to the number to be examined, and the second one is the check type (from 1 to 3).
You should write four sub functions to check the property of the number. If the number is this type of number, return 1
; else return 0
. At last, you should print the output.
- If type is
1
, check whether the number is an abundant number or not. In number theory, an abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. The integer 12 is an abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16. - If type is
2
, check whether the number is a Fibonacci number or not. An integer is a Fibonacci number if it is one of the numbers in the Fibonacci sequence \(a_0, a_1,\dots, a_n,\dots\) , where \(a_0 = 0, a_1 = 1\). - If type is
3
, check whether the number is a triangular number or not. The triangle number will be in the form of \[\frac{n(n+1)}2.\]
Sample
Sample #1
Sample Input
21 3
Sample Output
1
Sample #2
Sample Input
34 2
Sample Output
1
Sample #3
Sample Input
11 1
Sample Output
0
Note: the program will keep prompting for new input if the type is not in
the range of 1-3 (you do not need to print extra messages)
Homework 4
- Status
- Finished
- Problems
- 5
- Open Since
- 2020-07-01 00:00
- DDL
- 2020-07-07 23:59
- Extension
- 48.0 hour(s)