Advertisement
teslariu

multi

Apr 28th, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4.  
  5. """
  6. Escribir una función que, dado un número máximo, retorne una lista con
  7. todos los números desde 1 hasta dicho número que sean simultáneamente
  8. múltiplos de 3 y de 5 (usar la operación resto con el carácter %).
  9.  
  10. >>> multiplos(100)
  11. [15, 30, 45, 60, 75, 90]
  12. """
  13.  
  14. def multiplos(numero):
  15.     lista = []
  16.     for x in range(1,numero):
  17.         if x%3 == 0 and x%5 == 0:
  18.             lista.append(x)
  19.     return lista
  20.    
  21.    
  22. numero = int(input("Ingrese un nro: "))
  23. output = multiplos(numero)
  24. print(output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement