+ 8
Any suggestions to improve this code ?
6 Réponses
+ 11
👆 translated in python
+ 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
+ 4
@MMK good suggestion but i should be Initialized from 0
+ 3
add comments in it .
+ 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.