Comment

Comment by panda88888

At work so I haven’t watched the video yet, but my quick rationale is,

Let m = abs(n) It follows n = sign(n) * m We can work with m since sign(n) doesn’t affect the ones digit of n^5. More formally, n^5 = sign(n)^5 * abs(n)^5.

Let m = 10 * b + a, where b = floor(m/10) a = m % 10

Essentially we extract the ones digit as a.

m^5 = (10 * b + a)^5 If we expand the terms, only a^5 affects the ones digit. The remaining has at least one 10 as factor.

Quick python script will verify a^5 has a as the ones digit for 0...9.

  for a in range(10):
      print(pow(a, 5) == a) 
Edit: fixed formatting
parent panda88888 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton