include "NSLog.incl" _thereIsHope = _true nsLogSetTitle(@"Curzon numbers in Futurebasic") NumberFormatterRef form : form = fn NumberFormatterInit NumberFormatterSetPositiveFormat( form, @"#,###,###" ) local fn comma( n as uint32, pad as byte )as CFStringRef CFStringRef s = fn NumberFormatterStringFromNumber( form,¬ fn NumberWithInteger( n ) ) end fn = fn StringWithFormat(@"%@%@", right(@" ", pad-len(s)), s) local fn powMod(b as uint64, p as uint64, m as uint64) as uint64 uint64 x = 1 while p if (p & 1) then x = (x * b) % m b = (b * b) % m p = p >> 1 wend end fn = x local fn curzon CFStringRef s uint64 k, n, kn1, count for k = 2 to 12 step 2 n = 1 : count = 0 : kn1 = k * n + 1 : s = @"" NSLog( @"\n First 50 Curzon numbers with base = %d:", k ) while _thereIsHope if fn powMod(k, n, kn1) + 1 == kn1 count ++ select count case <= 50 : s = fn StringWithFormat(@"%@%@", s, fn comma(n, 7)) if (count Mod 10) = 0 Then s = fn StringWithFormat(@"%@\n", s) case 1000 : nslog( @"%@ 1,000th: %@", s, fn comma(n, 0)) break end select end if n++ : kn1 += k wend next end fn fn curzon handleevents