This python program makes my cpu reach its max limit:
x = int(input())
c = 0
while x != 0:
b= x//10
if b % 2 == 0 :
c+=1
print(c)
Is this normal ? When it reaches max cpu the Repl doesn’t work anymore and my code doesn’t run. plz help
This python program makes my cpu reach its max limit:
x = int(input())
c = 0
while x != 0:
b= x//10
if b % 2 == 0 :
c+=1
print(c)
Is this normal ? When it reaches max cpu the Repl doesn’t work anymore and my code doesn’t run. plz help
I have the same problem. I even just open a file and it happens.
Have you found a solution?
Thank you for answering either way, its nice to see that I’m not the only one
Yeah that’s just replit… they decreased the CPU to the point where you can’t even run simple programs because they haven’t revamped their architecture to use less CPU…
Occasionally do kill 1 in a shell. This seems ti calm the cpu somewhat …
Also thought that maybe the while loop was infinite so i tried this
x = int(input())
c = 0
while x != 0:
x= x%10
if x % 2 == 0 :
c+=1
print(c)
Same thing it doesn’t print what its supposed to.
How do you kill it ?
Could you format your code using ```py as it could be a problem with your indentation.
For example:
print("Hello, world!")
In which part of the code ?
Open the shell
tab (go to tools → Shell) and type kill 1
Your entire code, or you can send a link to your Repl (not invite).
Where is the link ? Cant find it
Just copy the url in the editor, at the top of your screen
Yep, that’s it.
When 0 is inputted it works:
But when a different number is inputted, it seems to infinitely take input.
Is this the desired behavior? (I’d assume not)
No its supposed to tell me the number of numbers divisble by 2
What do you mean by this?
Btw your code is an infinite loop, so that might be your problem not the usual cpu getting busy catching butterflies problem.
You need to put the input comment in the while loop (I would assume)
Like how many digits of the number are divisible by 2