Python Forum
CPU utilisation is confusing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CPU utilisation is confusing
#5
I'm new to this stuff so it's nothing too impressive
import random
import math
coprime = 0
cofactor = 0
sets = 0
while(sets<10000):
    random1 = random.randint(1, 1000)
    random2 = random.randint(1, 1000)
    i = 2
    while(True):
        if i==random1 or i==random2:
            coprime = coprime + 1
            break
        elif random1%i==0 and random2%i==0:
            cofactor = cofactor + 1
            i = i + 1
            sets = sets + 1
(it's still running btw, any help with improving efficiency would be greatly appreciated but I'm ok with leaving this to run)
Reply


Messages In This Thread
CPU utilisation is confusing - by Bidgey225 - Mar-19-2017, 08:16 PM
RE: CPU utilisation is confusing - by Ofnuts - Mar-19-2017, 09:17 PM
RE: CPU utilisation is confusing - by Bidgey225 - Mar-19-2017, 09:38 PM
RE: CPU utilisation is confusing - by Ofnuts - Mar-20-2017, 08:35 AM
RE: CPU utilisation is confusing - by nilamo - Mar-19-2017, 10:14 PM
RE: CPU utilisation is confusing - by Bidgey225 - Mar-20-2017, 06:28 AM
RE: CPU utilisation is confusing - by nilamo - Mar-20-2017, 01:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python list out top 10 Memory utilisation mg24 0 846 Nov-20-2022, 10:51 PM
Last Post: mg24
  Confusing in [for loop] topic Sherine 11 3,703 Jul-31-2021, 02:53 PM
Last Post: deanhystad
  Confusing logic Blob 4 2,464 Nov-18-2019, 03:26 AM
Last Post: Blob
  Confusing output from 2to3 about what files need change Moonwatcher 1 4,875 Dec-30-2018, 04:07 PM
Last Post: Gribouillis
  IndentationError message could be confusing to new programmers insearchofanswers87 1 2,383 May-16-2018, 05:05 PM
Last Post: Larz60+
  Confusing Math DrJu 2 3,294 Jan-18-2018, 10:47 PM
Last Post: Windspar
  Some Confusing Program Errors (Newbie stuff) WildPictus 1 2,828 Sep-03-2017, 05:00 PM
Last Post: hbknjr

Forum Jump:

User Panel Messages

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