0
Someone can help me with this code?
The code does not return ca correct value no matter what number i introduced. This is the code: https://code.sololearn.com/c5i0cVKY7yam/?ref=app
2 Answers
+ 11
The code works fine. You are just not getting the output you want because integer division takes place on line 18. The variable f itself is of type integer. As a result, f will always be 0. Instead, you may declare f as float, and do something like:
f = 1/float(x);
+ 1
Thanks , for the answer, now the code works fine.
Thank you.