発言者: 石原 守
発言日: 2014 01/11 17:02
wikipediaを見ていてウラムの螺旋というものが載っていたので
1000くらいまで表示するプログラムを書いてみました。手直しに飽きたので。。。
ものすごく時間がかかります。
\documentclass[a4j]{jarticle}
\usepackage{emathP}
\useperlpm{POSIX}
\begin{document}
\def\sosuuT{1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,
151,157,163,167,173,179,181,191,193,197,199,
211,223,227,229,233,239,241,
251,257,263,269,271,277,281,283,293,
307,311,313,317,331,337,347,349,
353,359,367,373,379,383,389,397,
401,409,419,421,431,433,439,443,449,
457,461,463,467,479,487,491,499,503,509,521,523,541,
547,557,563,569,571,577,587,593,599,601,607,613,
617,619,631,641,643,647,653,659,661,673,677,683,
691,701,709,719,727,733,739,743,751,757,761,769,
773,787,797,809,811,821,823,827,829,839,853,857,
859,863,877,881,883,887,907,911,919,929,937,941,
947,953,967,971,977,983,991,997}
\csvhairetu*{\sosuuT}{Ptbl}%
\def\byouga#1{%
\ifnum#1<2
\else\ifnum#1<10
\def\x{2}
\def\z{2}
\else\ifnum#1<26
\def\x{10}
\def\z{4}
\else\ifnum#1<50
\def\x{26}
\def\z{6}
\else\ifnum#1<82
\def\x{50}
\def\z{8}
\else\ifnum#1<122
\def\x{82}
\def\z{10}
\else\ifnum#1<170
\def\x{122}
\def\z{12}
\else\ifnum#1<226
\def\x{170}
\def\z{14}
\else\ifnum#1<290
\def\x{226}
\def\z{16}
\else\ifnum#1<362
\def\x{290}
\def\z{18}
\else\ifnum#1<442
\def\x{362}
\def\z{20}
\else\ifnum#1<530
\def\x{442}
\def\z{22}
\else\ifnum#1<626
\def\x{530}
\def\z{24}
\else\ifnum#1<730
\def\x{626}
\def\z{26}
\else\ifnum#1<842
\def\x{730}
\def\z{28}
\else\ifnum#1<962
\def\x{842}
\def\z{30}
\else\ifnum#1<1089
\def\x{962}
\def\z{32}
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\def\i{#1}
\def\m{\z}
\IDiv\m{2}\n
\ISub\i{\x}\l
\IDivMod\l\m\k\j
\edef\r{sqrt((\n)**2+(-\n+1+\j)**2)}
\edef\a{RadDeg(atan((\j-\n+1)/\n))}
\perlrtenretu*{P(\r,\a+\k*90))}
\Put\P(0,0)[c]{\bfseries\i}
}
%
\def\byougaA#1{%
\ifnum#1<2
\else\ifnum#1<10
\def\x{2}
\def\z{2}
\else\ifnum#1<26
\def\x{10}
\def\z{4}
\else\ifnum#1<50
\def\x{26}
\def\z{6}
\else\ifnum#1<82
\def\x{50}
\def\z{8}
\else\ifnum#1<122
\def\x{82}
\def\z{10}
\else\ifnum#1<170
\def\x{122}
\def\z{12}
\else\ifnum#1<226
\def\x{170}
\def\z{14}
\else\ifnum#1<290
\def\x{226}
\def\z{16}
\else\ifnum#1<362
\def\x{290}
\def\z{18}
\else\ifnum#1<442
\def\x{362}
\def\z{20}
\else\ifnum#1<530
\def\x{442}
\def\z{22}
\else\ifnum#1<626
\def\x{530}
\def\z{24}
\else\ifnum#1<730
\def\x{626}
\def\z{26}
\else\ifnum#1<842
\def\x{730}
\def\z{28}
\else\ifnum#1<962
\def\x{842}
\def\z{30}
\else\ifnum#1<1089
\def\x{962}
\def\z{32}
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\def\i{#1}
\def\m{\z}
\IDiv\m{2}\n
\ISub\i{\x}\l
\IDivMod\l\m\k\j
\edef\r{sqrt((\n)**2+(-\n+1+\j)**2)}
\edef\a{RadDeg(atan((\j-\n+1)/\n))}
\perlrtenretu*{P(\r,\a+\k*90))}
\Put\P(0,0)[c]{\colorbox{red}{\rule[-2pt]{0pt}{1.5zw}\makebox[1.5zw]{\textcolor{black}{\bfseries\i}}}}
}
%
\def\owari{961}
%
\begin{center}
\scalebox{.8}{%
\begin{zahyou*}[ul=1.25zw](-15,15)(-15,15)\tiny
%
\def\O{(0,0)}
\Put\O(0,0)[c]{1}
%
\Ifor*\ii{2}{\owari}\Do{\byouga{\ii}}
%
\fboxsep=2pt\relax
\Ifor*\ival{2}{\PtblN}\Do{%
\edef\pval{\hairetu{Ptbl}{\ival}}%
\ifnum\pval>\owari
\else
\byougaA{\pval}
\fi
}%
\end{zahyou*}}
\end{center}
\end{document}
▼関連発言
│
└◆1170:ウラムの螺旋 [石原 守] 01/11 17:02
└◆1171:Re:ウラムの螺旋 [tDB] 01/13 08:11
└◆1172:Re[2]:ウラムの螺旋 [石原 守] 01/13 09:02<-last