Prob­lem

Com­par­ing two num­bers writ­ten in index form like 211 and 37 is not dif­fi­cult, as any cal­cu­la­tor would con­firm that 211 = 2048 < 37 = 2187.

How­ever, con­firm­ing that 632382518061 > 519432525806 would be much more dif­fi­cult, as both num­bers con­tain over three mil­lion digits.

Using base_exp.txt (right click and ‘Save Link/Target As…’), a 22K text file con­tain­ing one thou­sand lines with a base/exponent pair on each line, deter­mine which line num­ber has the great­est numer­i­cal value.

NOTE: The first two lines in the file rep­re­sent the num­bers in the exam­ple given above.

Solu­tion

This ques­tion looks tricky at first as work­ing out the actual value of each of the base/exponent pair in the file can take a looong time.. but as many oth­ers have sug­gested, you can com­pare the log­a­rithm of the actual value instead, which can be expressed in the fol­low­ing form:

image

which can be com­puted very quickly and the rest is easy.

Share

Leave a Reply