Jump to content

Smallest Multiple [Project Euler] [Python]

AustinB
Go to solution Solved by fizzlesticks,

Your check function will never return True, it will either be False or None.

I'm running this code that in theory shouldn't take longer than an minute, but I've ran it for at least 5 min with no results. Am I missing a infinite loop or something similar? Thanks in advanced.

import time as tdef check(x):    for i in range(11,21):        if x % i == 0:            continue        else:            return False        return Truex =  2520while not check(x):    x += 2520print (x)t.sleep(100)

More info: https://projecteuler.net/problem=5

 

P.S. I don't want you to give me the answer.

Looking for a Programming Project take a look here!

http://linustechtips.com/main/topic/407332-looking-for-a-project-idea-start-here/

Link to comment
Share on other sites

Link to post
Share on other sites

Your check function will never return True, it will either be False or None.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks, gotta love non-syntax errors.

Using a good IDE like Visual Studio or PyCharm would catch those things for you.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

Using a good IDE like Visual Studio or PyCharm would catch those things for you.

Been using Atom, cause when I initially tried downloading PyCharm it  would quit the download half way through. Getting kind of sick of not having a debugger to read from and spamming the app to read the error. Thanks

Looking for a Programming Project take a look here!

http://linustechtips.com/main/topic/407332-looking-for-a-project-idea-start-here/

Link to comment
Share on other sites

Link to post
Share on other sites

One elementary way to diagnose stuff like this is to spam print statements.

I own and use, sorted from newest to oldest: SteelSeries 6Gv2. Microsoft SideWinder X4. Mionix Naos 7000. Zowie EC1 Evo. Microsoft SideWinder X8. Microsoft IntelliMouse Explorer 3.0. Dell U2414H. Samsung P2270H. AKG K273 Pro. Sennheiser HD555. Razer Goliathus Speed Medium. Func 1030 L. Qpad CT Medium.

I used to own: Razer DeathAdder 3G. Razer Krait. IntelliMouse Optical 1.1. SteelSeries QcK.

Link to comment
Share on other sites

Link to post
Share on other sites

This can be done pretty easily mathematically.

 

Also, another way of doing it would be to calculate the smallest common factor of the numbers.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks, gotta love non-syntax errors. Not going to say the solution as it is a Project Euler question.

 

Just FYI, non-syntax errors are known as semantic errors. :)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×