|
In part 1 of this series, I explained how to make a one-to-one correspondence between the counting numbers and ordered pairs. Then I provided an example, illustrating the procedure. Here, I provide a calculator to allow you to quickly find the nth ordered pair:
> > |
On 11/14/00 8:29:23 PM, Andrew Critch wrote: Can ANYBODY help me find a function to find the nth element of this series? {(1,0), (1,1), (0,1), (-1,1), (-1,0), (-1,-1), (0,-1), (1,-1), (2,-1), (2,0), ...} It's a square spiral circling out from the origin. Any help would be greatly appreciated. |
Here is a table of the first 100 ordered pairs, and below
that a chart depicting the square spiral.
|
Here is a chart showing the first 100 ordered pairs.
|
Notes about the calculations used by this Counting Calculator
In case you didn't know, "floor" is a function such that floor(x) returns the largest integer that is not larger than x. Also, the notation of a?b:c is used in many programming languages, such as C and Java, and it means if condition a is true, the value is b; otherwise the value is c. These can be nested, so that a?b:c?d:e means if a is true then the value is b; else if c is true then the value is d; otherwise the value is e. OK, this ends today's lesson on programming. But if you want to explore further, click "View", then click "Source" in your browser. You can see the JavaScript program statements in the function called "Calc()" which are executed on your PC when you use this calculator. OK, I'm really done now. Good night.
Read the introduction to the Square Spiral and its inverse.
The webmaster and author of this Math Help site is Graeme McRae.