+ 1
Factors and For Loops
Hello! I wrote the following code: https://code.sololearn.com/cT0ubyp9sr0E/?ref=app I was wondering how I could get it to display the factors from large to small, also how do I get rid of the comma on the last factor? For example (*WANT*): 2: 2, 1 3: 3, 1 4: 4, 2, 1 Right now, my code displays: 2: 1, 2, 3: 1, 3, 4: 1, 2, 4, Thank you!!!
3 Respuestas
+ 5
Reverse your loop so i is decremented every iteration. This will display your factors in descending order.
Print the first member, and in the following loop, print the comma first, then the factor.
https://code.sololearn.com/cvrFMB45I1Kb/?ref=app
+ 1
thanks so much!!
+ 1
Miqaela Weller You're welcome.