+ 2

For loops

How do I compute all multiples of 3&5 in a range?

13th Sep 2019, 12:02 PM
Onimisi
Onimisi - avatar
4 Answers
+ 2
Python # Calculates sum of multiples of  # a number upto N def calculate_sum(a, N):        # Number of multiples     m = N / a        # sum of first m natural numbers     sum = m * (m + 1) / 2        # sum of multiples     ans = a * sum        print("Sum of multiples of ", a,           " up to ", N, " = ", ans)    # Driver Code calculate_sum(7, 49)
13th Sep 2019, 12:17 PM
Роман Львов
Роман Львов - avatar
+ 2
Роман Львов Nice code 👍 Please verify code is runnable, it didn't run when I checked it out. There are invalid characters that prevents the code to run. Try viewing from a web browser, those characters will show up. (Edit) Alternatively view the code in a code editor, then switch encoding to ANSI. Those characters will also show up then.
13th Sep 2019, 1:05 PM
Ipang
+ 2
Python requires formatting of blocks with indentation. Work issue : https://code.sololearn.com/cl3ThlJYtX6Q/?ref=app
13th Sep 2019, 1:51 PM
Роман Львов
Роман Львов - avatar
0
I'm lost. Is this python?
13th Sep 2019, 12:16 PM
Onimisi
Onimisi - avatar