Bijective Function from N to N^2: Examples and Help

  • Thread starter Thread starter Anzewill
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
Anzewill
Messages
1
Reaction score
0
Anyone can give me a example of a bijective fuction from N to N^2?
 
Physics news on Phys.org
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].