% This file is generated by AMADEUS.
{\scheme 
\modulesketchB{
}{
\simplehead{
{\it Fibonacci\_algarv}$(n)$}
\simpleheadc{
}{
Antud: naturaalarv $n>2$}
\simpleheadc{
}{
Tulemus: tagastatakse v"ahim algarvuline Fibonacci arv, }
\simpleheadc{
}{
\hspace{50pt} mis on suurem kui $n$}
}{
\simplebranch{
}{
}{
\primitivec{
}{
 abimuutujad: $e, f, g, k$}
\primitive{
 $e := f := 1$}
\loopsketch{
}{
\primitivec{
}{
$e$ ja $f$ on kaks j"arjestikust Fibonacci arvu}
\primitivec{
  $g := e + f$}{
$g$ on j"argmine Fibonacci arv}
\primitivec{
}{
leida uus paar $(e, f)$:}
\primitive{
  $e := f$}
\condition{
  $(f := g) \leq n$}
\weakarrow{\wlenB}{\wshiftB}{
\primitive{
}
}
\primitivec{
}{
$f > n$, kontrollida tuleb veel $f$ algarvulisust }
\condition{
  $f$ mod $2 = 0$}
\primitivec{
}{
$f$ on paaris}
\weakarrow{\wlenB}{\wshiftB}{
\primitive{
}
}
\primitivec{
}{
$f$ on paaritu}
\loopsketchB{
}{
\loophead{
$k = 3, 5, \ldots, \sqrt{f}$}
}{
\simplebranch{
}{
}{
\condition{
$f$ mod  $k = 0$}
\primitivec{
}{
$f$ pole algarv, sest jagub arvuga $k$}
\weakarrow{\wlenC}{\wshiftC}{
\primitive{
}
}
}
}
\arrow{\lenC}{
\primitivec{
($f$) }{
$f$ osutus algarvuks, l~opetada ja tagastada vastus}
}
}
}
}
}