Dan - 1 month ago 8

Python Question

I am trying to write a program in python 2.7 that will first see if a number divides the other evenly, and if it does get the result of the division.

However, I am getting some interesting results when I use large numbers.

Currently I am using:

`from __future__ import division`

import math

a=82348972389472433334783

b=2

if a/b==math.trunc(a/b):

answer=a/b

print 'True' #to quickly see if the if loop was invoked

When I run this I get:

`True`

But 82348972389472433334783 is clearly not even.

Any help would be appreciated.

Answer

That's a crazy way to do it. Just use the remainder operator.

```
if a % b == 0:
# then b divides a evenly
quotient = a // b
```