F stern_brocot(predicate = series -> series.len < 20) V sb = [1, 1] V i = 0 L predicate(sb) sb [+]= [sum(sb[i .< i + 2]), sb[i + 1]] i++ R sb V n_first = 15 print(("The first #. values:\n ".format(n_first))‘ ’stern_brocot(series -> series.len < :n_first)[0 .< n_first]) print() V n_max = 10 L(n_occur) Array(1 .. n_max) [+] [100] print((‘1-based index of the first occurrence of #3 in the series:’.format(n_occur))‘ ’(stern_brocot(series -> @n_occur !C series).index(n_occur) + 1)) print() V n_gcd = 1000 V s = stern_brocot(series -> series.len < :n_gcd)[0 .< n_gcd] assert(all(zip(s, s[1..]).map((prev, this) -> gcd(prev, this) == 1)), ‘A fraction from adjacent terms is reducible’)