← RoseCode

ROSECODE 082

Pragma Series: Sorted Radical Function

elasolova · TimeRace ·

The original interaction is no longer available. Any surviving program is preserved as source code.

The radical of n, r(n), is the product of distinct prime factors of n. For example, 156 = 2 x 2 x 3 x 13, so r(156) = 2 x 3 x 13 = 78. If we calculate r(n) for 1 <= n <= 10, then sort them on r(n), and sorting on n if the radical values are equal, we get:
1,2,4,8,3,9,5,6,7,10
let S(k) be the kth element on the sorted list. So S(3) = 4, S(7)=5 etc. p82.php (original interactive page unavailable) will print random M and N values where r(i) is sorted for 1 <= i <= M and the answer is S(N). POST to p82.php as ans=S(N)&submit82=true. You have 1.12 secs to calculate!!.
Note: M will be between 8000 and 10000, whereas N will be between 1000 and 3000.
Fix: Fixed index problem. Now the S array starts from 1 as described above instead of starting from 0.