Bijective function from N to N²?

  • Thread starter Anzewill
  • Start date
2 replies · 2K views · last reply
Anzewill
Messages
1
Reaction score
0
Anyone can give me a example of a bijective fuction from N to N^2?
 
I can't give you a simple "formula" but here is how to get a bijective function:

Write the numbers 1, 2, 3, ... horizontally and to left of "1" and slightly below write 1, 2, 3, ... vertically so that the cell below "m" and to the right of "n" is the pair (m,n). Now start at (1, 1) and "zigzag" through that array. That is, go from (1,1) horizontally to (2, 1) then diagonally, down and left, to (1,2), down to (1, 3), diagonally up and right to (2,3) and (3, 1), right to (4, 1), diagonally down to (3,2), etc.
 
Or for a simple formula try [itex](m,n)\rightarrow 2^m(2n+1)-1[/itex].