This is a good question. I had the same question few years ago, but did some research, but I can't really confirm what I had found. Anyway, I heard there was a case with selling mobile refills cheaper very long time ago. Probably around the time when the mobiles were kicking off in here and mobile refills weren't such a hype. How people got the codes, that I don't know, but now I hear mobile phone companies use changing algos to generate the numbers.
And if you think about it, it's a logical solution against such fraud, but it gets expensive for the mobile companies to think of new algos every month, maybe every year, or half a year, so they probably use the same algo where a value can be changed to produce different results.
But if you think about it, when you buy a refill, at some places a doo-hickey generates you a number directly, meaning you don't buy pre-printed numbers... then how that stuff gets done? either the machine gets updated each time an algo changes... or the algo doesn't change?
This is all interesting and I'd like to hear more... I was just brainstorming here