Short t, i, j, k, m Double a(9), z Double phi, psi CFStringRef s print @"Benford:" for i = 1 to 9 a(i) = log10( 1 + 1 / i ) print fn StringWithFormat( @"%.3f ", a(i) ), next // Fibonacci according to DeMoivre and Binet for t = 1 to 9 : a(t) = 0 : next // Clean array phi = ( 1 + sqr(5) ) / 2 psi = ( 1 - sqr(5) ) / 2 for i = 1 to 1000 z = ( phi^i - psi^i ) / sqr( 5 ) s = fn StringWithFormat( @"%e", z) // Get first digit t = fn StringIntegerValue( left( s, 1 ) ) a(t) = a(t) + 1 next print @"\n\nFibonacci:" for i = 1 to 9 print fn StringWithFormat( @"%.3f ", a(i) / 1000 ), next // Multiplication tables for t = 1 to 9 : a(t) = 0 : next // Clean array for i = 1 to 10 for j = 1 to 10 for k = 1 to 10 for m = 1 to 10 z = i * j * k * m s = fn StringWithFormat( @"%e", z ) t = fn StringIntegerValue( left( s, 1 ) ) a(t) = a(t) + 1 next next next next print @"\n\nMultiplication:" for i = 1 to 9 print fn StringWithFormat( @"%.3f ", a(i) / 1e4 ), next // Factorials according to DeMoivre and Stirling for t = 1 to 9 : a(t) = 0 : next // Clean array for i = 10 to 110 z = sqr(2 * pi * i ) * (i / exp(1) )^i s = fn StringWithFormat( @"%e", z ) t = fn StringIntegerValue( left( s, 1 ) ) a(t) = a(t) + 1 next print @"\n\nFactorials:" for i = 1 to 9 print fn StringWithFormat( @"%.2f ", a(i) / 100 ), next handleevents }