int dist( 7 ) void local fn radicals( max as int ) print @"\n Radicals of first 50 integers:" for int v = 1 to max int count = (v = 1), rad = 1, incr = 2, factr = 5, sq = sqr(v), num = v while !( num & 1 ) rad = 2 : count = 1 num >>= 1 wend if !( num % 3 ) rad *= 3 : count ++ do num /= 3 until ( num % 3 ) end if while num > 1 if !( num % factr ) rad *= factr : count ++ do num /= factr until ( num % factr ) end if factr += incr : incr ^^= 6 if factr > sq then factr = num wend dist(count)++ //breakpoint v,rad, count select v case < 51 : printf @"%4d\b", rad if !( v % 10 ) then print case 99999, 499999, 999999 printf @"\n Radical of %6d is %6d\b", v, rad end select next num printf @"\n\n Distribution of factor counts from 1 to 1000000" for int i = 1 to 7 printf @" %d: %6d", i, dist(i) next end fn // MAIN CFTimeInterval t : t = fn CACurrentMediaTime fn Radicals( 1000000 ) printf @"\n Calc time: %.3fsec", fn CACurrentMediaTime - t HandleEvents