+ 4
[SOLVED] Why does my program output "inf"??
The program is supposed to print an approximation of pi. Why am I getting inf? https://code.sololearn.com/c2vgob6m3Vrf/?ref=app https://www.sololearn.com/post/748624/?ref=app
3 Respostas
+ 3
in your first if statement, you divide 4 by 0. That seems to be a problem
+ 4
Slick Benjamin Jürgens you are right, and I didn't even needed to start the loop from 1.
Now I know that I need to check for this kind of stuff when I get "inf"
Thank you so much 🤗
+ 2
In the first iteration of the loop i=1, so i*i*i-i=1-1=0 and 4.0/0=inf