Any suggestions to improve this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Any suggestions to improve this code ?

https://code.sololearn.com/clR6kc3LjO0K/?ref=app

9th Jun 2017, 3:48 AM
Sahil Choudhary
Sahil Choudhary - avatar
6 Answers
+ 11
👆 translated in python
9th Jun 2017, 4:25 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
9th Jun 2017, 4:24 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 4
- Initialize i to 1 and place the "i++" Statement at the end of the while block. - Set your while limit to "num" - Print out "num" after the while loop or set the while condition to "i <= num" to include the division by the number itself - Add Comments about what the code does at critical lines
11th Jun 2017, 11:42 AM
MMK
MMK - avatar
+ 4
@MMK good suggestion but i should be Initialized from 0
13th Jun 2017, 11:41 AM
Sahil Choudhary
Sahil Choudhary - avatar
+ 3
add comments in it .
9th Jun 2017, 6:09 AM
Srishti Aggarwal
Srishti Aggarwal - avatar
+ 2
@Sahil Choudhary Why? Division by zero is not defined anyway. Initialize it to 1 and put i++ at the end of your while loop.
13th Jun 2017, 12:30 PM
MMK
MMK - avatar