Mar-24-2020, 10:30 PM
Hello,
./multiple_nombre_v3.py
(15, 1)
(30, 2)
(45, 3)
(60, 4)
4
My script is giving the multiple of a number (here 15 for example) and the script is working.
I want to optimize it. I have these two lines print(i,r) and return(r ). Is there a way I can get rid of one of these two lines and yet have the correct output giving only the multiple of a number ? I am asking this because the return(r ) sends "4" and in the 'if condition' I did not find an another way besides "print(i,r)" to show the multiples of a number.
#!/usr/bin/python # -*- coding: utf-8 -*- # Les nombre multiples de n compris entre 1 et 60 def multiple(n): for i in range(1,61): r=i//n if i%n==0: print(i,r) return(r) print(multiple(15))The output of the script is like this :
./multiple_nombre_v3.py
(15, 1)
(30, 2)
(45, 3)
(60, 4)
4
My script is giving the multiple of a number (here 15 for example) and the script is working.
I want to optimize it. I have these two lines print(i,r) and return(r ). Is there a way I can get rid of one of these two lines and yet have the correct output giving only the multiple of a number ? I am asking this because the return(r ) sends "4" and in the 'if condition' I did not find an another way besides "print(i,r)" to show the multiples of a number.