0

Help me to fix the code

num=1 i=2 while (i<21): if (num%i==0): i+=1 else: i=2 num+=1 print (num) this program is built to find the smallest number that can be divided by 1-20 without a remainder. http://www.sololearn.com/app/JUMP_LINK__&&__python__&&__JUMP_LINK/playground/cL3cOicAFuKl/

8th Jul 2020, 11:19 PM
eliya melamed
eliya melamed - avatar
6 Réponses
+ 2
Is this what you were trying to do? res = 1 for i in range(1,21): res*=i result = res//1000 print(result,'\n') for i in range(1,21): print(result/i)
9th Jul 2020, 12:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
this is what I am trying to achieve https://projecteuler.net/problem=5
9th Jul 2020, 6:49 AM
eliya melamed
eliya melamed - avatar
+ 1
eliya melamed Same principal applies. lst = [5,7,8,9] res = 1 for i in lst: res *= i print(res)
9th Jul 2020, 7:13 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Post your code and share the link instead, it will make it easier for people to make edits and answer your question better
9th Jul 2020, 12:13 AM
Adeniyi Olaitan
Adeniyi Olaitan - avatar
0
This is an edit to my first post, taking into consideration that I am still not sure of what you are trying to achieve. from sympy import isprime req_nums = [] [req_nums.append(i) for i in range(1,21) if isprime(i)] req_nums.append(9) req_nums.append(8) req_nums.remove(2) print(req_nums) total = 1 for i in req_nums: total *=i print('total=>', total,'\n') for i in range(1,21): print(total/i) print('\noriginal bit') #Is this what you were trying to do? res = 1 for i in range(1,21): res*=i result = res//1000 print('total=>',result,'\n') for i in range(1,21): print(result/i)
9th Jul 2020, 6:47 AM
Rik Wittkopp
Rik Wittkopp - avatar