Hey everyone, I'm the new guy ;)

I'm trying to develop a poker-tool and I'm having a little tought-problem.

There are 1326 poker starting hands. I want to be able to identify each of them with a number between 0 and 1325. Then, when I have an input of f.e. 768, I want to be able to reconstruct the two holecards, that made up this hand. Holecards are numbers between 0..51 (for a deck of 52cards).

Obviously I want to be able to do it the other way around as well, which I believe is alot easier tho.

I came up with the following idea:

Let { i, j } be a pair of cards. Then I get the hand h with

i*51 + j ; i<j

I then thought I could reconstruct the cards by

h % 51 = j

h-j / 51 = i

But that doesnt seem to be the solution :\

Can anyone help me out here? Just can't figure it out.