In some exercises in class, you will have to find the multiple of a number. This logic of the multiples of a number is based on a simple rule, a number is a multiple of another when dividing the number you need to know if it is a multiple, between the number as such, for example, to know if 15 is a multiple of 5 , the remainder of the operation by dividing 15/5 should be 0:
Note: we are talking about the remainder of the operation, not the result of the division, that is, 15/3 = 3, however we need the remainder of said operation, that is, the modulo operator (MOD or% in PseInt).
# Modulo operator
15 % 5 = 0
This means that when dividing 15 by 3, the remainder of said operation is 0, therefore 15 is a multiple of 5. Now, if you need to find the first X or N multiples of some number, you must resort to an indefinite cycle that it will stop only when some counter / flag variable tells it to end. In this case we will work with 3 variables that will function as counters. The counter variable will contain the number that we are going to divide to know if it is a multiple of the entered number, therefore it will gradually increase by 1 until the "limit" variable that contains the current index of the total numbers that have been declared as multiples of the number entered:
Algoritmo NPrimerosMultiplos
Definir _numero, contador, limite, numeroMultiplos Como Entero
Escribir "Enter the number of multiples to calculate:"
Leer numeroMultiplos
Escribir "Enter the number value to calculate your first", numeroMultiplos ," multiples:"
Leer _numero
limite = 1
contador = 1
Repetir
Si contador MOD _numero = 0 Entonces
Escribir limite, ") ", contador
limite = limite + 1
FinSi
contador = contador + 1
Hasta Que limite > numeroMultiplos
FinAlgoritmo
Happy coding ❤️!