# Tirooyin soo noqnoqonaya0519

Dhowrkii maalmood ee la soo dhaafay, waxaan ku baranayay StackExchange su'aasha soo socota ee ku saabsan isku dheelitirnaanta tirada. Waxaan raadineynaa qaaciido xiran oo loogu talagalay iskuduwaha walxaha $$n$$ -th ee isku-dhafan isku-dhafan ee soo socda, kaas oo ka sii ballaaranaya asalka dibedda iyo ka sii sii durugsanaanta:

..  9 10 11 12
23  8  1  2 13
22  7  0  3 14
21  6  5  4 15
20 19 18 17 16

Marka hore waxaan u kala qaybinaynaa tirooyinka dabiiciga kooxaha soo socda:

$$G_1 = \{ 1,...,8 \}\\G_2 = \{ 9, ..., 24 \}\\G_3 = \{ 25, ... 48 \}\\...\\G_k = \left\{ (2k-1)^2, (2k+1)^2 - 1 \right\}$$

Waxaan wacnaa

$$a^2 = \left(\left \lfloor \left( \frac{\left \lfloor \sqrt{n} \right \rfloor + 1}{2} \right) \right \rfloor \cdot 2 - 1 \right)^2$$

nambarka bilowga ee koox.

Kooxda gudaheeda waxaa ku jira afar koox-hoosaad oo is le'eg $$G_1$$ waa $$g_1 = \{ 1,2 \}, g_2 = \{ 3,4 \}, g_3 = \{ 5,6 \}, g_4 = \{7,8\}$$ ). Haddii $$n$$ hal koox-kooxeed una gudubto ku xigga, jihada dariiqa wareegga (saacad ahaan tusaalaheenna) sidoo kale isla waqtigaas ayaa la beddelayaa. Waxaan kuheleynaa jihada hada $$b \in \{0,1,2,3\}$$ adoo uqaybinaya booska $$na^2$$ koox gudaheeda tirada walxaha kujira koox hoosaad:

$$b = \left \lfloor \frac{ n - a^2 }{ \text{abs}\left( a \right) + 1 } \right \rfloor$$

Hadda waxaan go'aan ka gaari karnaa $$g_n$$ ugu horreeya koox-hoosaad $$g_n$$ tiro badan $$b$$ lambarka $$a+1$$ ee xubno ku dhex jira koox lambarka ugu horreeya $$a^2$$:

$$c = a^2 + b \cdot (a+1)$$

Hadda waxaan ku go'aamin karnaa kormeer fudud:

$$x_{right} = \left(n - c - \frac{ a + 1 }{2}+1\right),\, y_{right} = \left(\frac{ a + 1 }{2}\right) \\ x_{bottom} = \left(\frac{ a + 1 }{2}\right),\, y_{bottom} = (-1) \cdot \left( n - c - \frac{ a + 1 }{2}+1\right) \\ x_{left} = (-1) \cdot \left(n - c - \frac{ a + 1 }{2}+1\right),\, y_{left} = (-1) \cdot \left(\frac{ a + 1 }{2}\right) \\ x_{top} = (-1) \cdot \left(\frac{ a + 1 }{2}\right),\, y_{top} = \left( n - c - \frac{ a + 1 }{2}+1\right)$$

Waxaan dooneynaa inaan ku matalno $$f(n)$$ wakiil matalaad xiran iyo waliba iyadoo aan kiisaska la kala saarin. Waxaan u adeegsannaa shaqada Signum, waxaan ku sharaxay nidaamka halkan . Si aan u helno qaaciido saafi ah oo shaqeysa $$n$$ , waan helnaa:

Caawinta SVG.js , waxaan ku arki karnaa muuqaalkan yar in wax walba runti shaqeeyaan:

See the Pen ulam spiral by David Vielhuber (@vielhuber) on CodePen.

Wareegtada waxaa sidoo kale loo yaqaanaa ' Ulam's muquuninta' waxayna leedahay xiriir xiiso leh oo ku saabsan tirooyinka ugu muhiimsan.

Dib u laabo