Sum Squared Digits Function: Difference between revisions

From programming_contest
Jump to navigation Jump to search
imported>Kmk21
Created page with "This problem asks you to convert an input number to a given base and then compute the sum of the squares of the digits. The only challenge here is to know how to convert base..."
 
(No difference)

Latest revision as of 22:42, 27 December 2017

This problem asks you to convert an input number to a given base and then compute the sum of the squares of the digits.

The only challenge here is to know how to convert bases, and it's not even that hard, since the answer does not need to be constructive...we only need the sum.

  1. while number is not 0
  2. ans += (number % base)^2
  3. ans /= base