The formulas for working out your stats are:

```
HP = ((2*Base + IV + EV/4 + 100) * Level) / 100 + 10
Stat = (((2*Base + IV + EV/4) * Level) / 100 + 5) * Nature
```

So to work out an IV or EV for a stat, it's a matter of simply reversing the calculation. If you're not good at algebra it can be a little difficult so here they are. For HP:

```
((HP - 10) * 100) / Level = 2*Base + IV + EV/4 + 100
IV = ((HP - 10) * 100) / Level - 2*Base - EV/4 - 100
EV = (((HP - 10) * 100) / Level - 2*Base - IV - 100) * 4
```

For the other stats:

```
((Stat/Nature - 5) * 100) / Level = 2*Base + IV + EV/4
IV = ((Stat/Nature - 5) * 100) / Level - 2*Base - EV/4
EV = (((Stat/Nature - 5) * 100) / Level - 2*Base - IV) * 4
```

These formulas have been the same since Generation 3, and as far as I know haven't changed in X/Y. The Nature modifier is 1.1 for positive nature, 1 for neutral, 0.9 for negative nature.

Note: I'm using the normal mathematical "order of operations" to make the formulas clearer, multiplication/division comes first, so for example `IV + 2*Base + EV/4 + 100`

is the same as `IV + (2*Base) + (EV/4) + 100`

.