0
What is the problem with my code? Please help...
more description is in the code itself. ggt and kgv is German for greatest common devisor and smallest common multiple. I don't know, whether these are the correct terms... :| https://code.sololearn.com/cCki7ssj0621/?ref=app
3 Antworten
+ 1
Put the print statement in your code and test with numbers 12 and 4. The print statement is the last line.
while (a!=1 or b!=1):
if a%c==0 and b%c==0:
ggt*=c
elif a%c==0 or b%c==0:
kgv*=c
if a%c==0:
a/=c
if b%c==0:
b/=c
else:
c=primNach(c)
print(a, b, c)
I think there is a bug if a number is divisible by the same prime more than once. Like 4.
4 / 2 = 2 2 / 2 = 1
0
Ist durchaus möglich das die App das nicht packt wenn du mit Primzahlen anfängst, ich würd dir empfehlen mal den euklidischen Algorithmus zu lernen und Merk dir kgv(a,b) = ab/ggt(a,b) das spart nochmal zeit
0
ok. danke für die antwort