Preloader
PseInt
  • Estimated reading time: 1 Minute

How to print the first N multiples of a number in PseInt

magzin

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 ❤️!

Related articles
How to resolve PseInt exception: ERROR 273 Debe haber un Proceso
10 Apr, 2021
  • Estimated reading time: 2 Minutes
How to print the first N numbers of the Fibonacci series in PseInt
20 Oct, 2020
  • Estimated reading time: 1 Minute
How to print the border of an empty square with asterisks in PseInt
20 Oct, 2020
  • Estimated reading time: 1 Minute
How to determine if a number is positive or negative in PseInt
20 Oct, 2020
  • Estimated reading time: 1 Minute
Weekly trending
How Modern Crown Technology Makes Dental Visits Easier
6 Jun, 2026
  • Estimated reading time: 10 Minutes
The Technology Behind Smarter Boat Navigation Systems
6 Jun, 2026
  • Estimated reading time: 2 Minutes
The Future of Human Machine Interfaces Is Simpler Than Ever
6 Jun, 2026
  • Estimated reading time: 2 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.