← RoseCode

ROSECODE 544

Distinct powers revisited

C_K_Yang · Programming ·

Consider all integer combinations of ab for 2a5 and 1b5:

21=2, 22=4, 23=8, 24=16, 25=32
31=3, 32=9, 33=27, 34=81, 35=243
41=4, 42=16, 43=64, 44=256, 45=1024
51=5, 52=25, 53=125, 54=625, 55=3125

If they are then placed in numerical order, with any repeats removed, we get the following sequence of 18 distinct terms:

2, 3, 4, 5, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

Given two integers N>1 and M>0, let R(N,M) be the number of distinct terms in the sequence generated by ab for 2aN and 1bM

For example, R(5,5)=18, R(102,103)=92715 and R(105,106)=99813359409

Find the last 20 digits of R(1021,1121)



This problem is a harder version of Project Euler Problem#29 (https://projecteuler.net/problem=29)