Python Forum
My code is taking longer time to give result
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My code is taking longer time to give result
#5
Don't search for it, build it. Start with 1. 1 evenly divides into that. 2 does not, and there is no common divisor, so multiply by 2 to get 2. 3 does not evenly divide into 2, and there is no common divisor, so multiply by 3 to get 6. 4 does not divide into 6 evenly, but it has a common divisor of 2. So multiply 6 by (4 / 2) to get 12. Keep going up to 20.

You would need to build a greatest common divisor function, (or use the one in the math or fractions module), but then you can build it piece by piece rather than searching for it, which should be faster.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: My code is taking longer time to give result - by ichabod801 - Feb-20-2019, 08:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Code works but doesn't give the right results colin_dent 2 709 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Beginner: Code not work when longer list raiviscoding 2 815 May-19-2023, 11:19 AM
Last Post: deanhystad
  math formula does not give the same result as bash script [SOLVED] AlphaInc 3 962 Apr-02-2023, 07:21 PM
Last Post: AlphaInc
  help me simple code result min and max number abrahimusmaximus 2 901 Nov-12-2022, 07:52 AM
Last Post: buran
  a longer docstring Skaperen 8 1,655 Aug-25-2022, 11:21 PM
Last Post: Skaperen
  Give visit number ( or counter) within the same time frame balthordu 1 934 Jun-27-2022, 09:51 AM
Last Post: Larz60+
  Can a program execute code in iPython shell and get result? deanhystad 3 1,724 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  code running for more than an hour now, yet didn't get any result, what should I do? aiden 2 1,492 Apr-06-2022, 03:41 PM
Last Post: Gribouillis
  Schedule a task and render/ use the result of the task in any given time klllmmm 2 2,081 May-04-2021, 10:17 AM
Last Post: klllmmm
  Assistance with running a few lines of code at an EXACT time nethatar 5 3,232 Feb-24-2021, 10:43 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020