Minimum
Write the function minimum(number_1, number_2)
that returns the minimum of the two parameters, number_1
and number_2
. The function should not use the built-in min
function.
Clamp
Write the function clamp(number, minimum, maximum)
that returns the result of clamping the specified number into the range [minimum, maximum]. That is, if number
is below minimum
, it returns minimum
, if number
is above maximum
, it returns maximum
, and otherwise it returns number
. The function should not use the built-in functions min
and max
.
Perfect Numbers
A perfect number is a positive integer that is the sum of all of its positive divisors, excluding itself. For example, the divisors of 6 are 1, 2, 3, and 6, and 1 + 2 + 3 = 6. It is an open problem in mathematics as to whether there are a finite number of perfect numbers.
Details
Create a program that prompts the user for a positive integer and prints all of the perfect numbers less than the specified positive integer.
Example
Enter a positive integer: 1000 The perfect numbers less than 1000 are... 6 28 496
Hint
Submission
Please show your source code and run your programs for the instructor or lab assistant. Only programs that have perfect functionality will be accepted as complete.