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

23rd May 2018, 4:12 PM
Feleon
3 odpowiedzi
+ 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
23rd May 2018, 5:26 PM
Paul
Paul - avatar
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
23rd May 2018, 4:22 PM
Max
Max - avatar
0
ok. danke für die antwort
23rd May 2018, 4:24 PM
Feleon