0

I started at university and programming in python 3.5 is one of our important courses. We use an online website to code and compile the programs but I like to save them on my computer as well but there is a slight error...

tolerantie = float(input("Tolerantie = "))

i = 0
fact = 1
nterm = float(1)
s = 0

while nterm > tolerantie:
    s += nterm
    i += 1
    fact *= i
    nterm = 1/fact

print s
print i

I use this program to approximate the number 'e' using Pycharm but my computer always gives the values s=2 and i=2 so I assume it doesn't execute the while-loop... Do I need to add something because it is in Pycharm because this program works perfectly on the server of the University?

Regards,

Sam VG
  • 143
  • 1
  • 2
  • 9

1 Answers1

0

In your case PyCharm uses python2.x to compile the script.
You can force division to be floating point in Pythno2.x or change pycharm configuration and choose Python3.5 interpreter then instead of print s use print(s).

Community
  • 1
  • 1
Kenly
  • 24,317
  • 7
  • 44
  • 60
  • Thnx man... I downloaded Pyhton 3.5 and changed the interpreter and now everything works fine :D – Sam VG Oct 02 '16 at 07:30