View the factors of a positive input number
(hint: x is a factor of N if the remainder of the integer division between N and x = 0 For example, the factors of 10 are: 1, 2, 5, 10)
The exercise extends as follows
Check if a given positive input number N is a perfect number
(hint: sum the factors of the numbers excluding itself and if the sum is equal to the number, the number is said to be perfect. For example, 6 is perfect because the factors are 1 + 2 + 3 = 6)
Again, it continues with the following exercise
Display the perfect numbers between 1 and 10000
which finds its solution in the video following this link
Having done the previous exercises, we are able to reason about prime numbers:
The following exercise is fundamental:
Write the code that checks if a positive integer input number N is a prime number
(Hint: prime numbers have no divisors excluding 1 and themselves. Factorize the numbers and count the factors of the numbers: if in the computation you exclude 1 and itself, the number of factors must be = 0, otherwise if you include 1 and itself, the sum of the factors is = 2)
Follow the video lesson and continue with the assigned exercises: