Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:35:56+00:00 2026-06-09T15:35:56+00:00

I have solved the project Euler problem 16 but discovered this rather novel approach

  • 0

I have solved the project Euler problem 16 but discovered this rather novel approach but I cannot get my head around the technique employed (from http://www.mathblog.dk/project-euler-16/):

int result = 0;

BigInteger number = BigInteger.Pow(2, 1000);

while (number > 0) {
    result += (int) (number % 10);
    number /= 10;
}

My version seems more conventional but I think the above approach is cooler.

var result = BigInteger
    .Pow(2, 1000)
    .ToString()
    .Aggregate(0, (total, next) => total + (int) Char.GetNumericValue(next));

How does the mathematics work on the first approach, it is cool, but I need some explanation to help me understand, so if someone would be so kind to explain to me I would really appreciate it.

NOTE: If I have posted in the wrong section please let me know the better place to ask.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:35:57+00:00Added an answer on June 9, 2026 at 3:35 pm

    value % 10 will return the last digit (remainder after dividing by 10). Dividing the integer by 10 will remove this number.

    Think of the number as a list, and you’re just dequeuing the list and summing the values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: I have solved the majority of this problem but have run into a
This is fairly 'math-y' but I'm posting here because it's a Project Euler problem,
I have solved this problem, I just need to know what to do. I
I have read a bunch of forums on this but none have solved my
I'm curious how others have solved this problem, and what problems might lurk behind
This is an Amazon interview Question.I have solved this problem in O(n) using dynamic
As some of you may notice this question is problem 16 from Project Euler
I have been trying to solve Project Euler's problem #59 for a while, and
I'm currently working on project euler problem 14 . I solved it using a
I am learning dynamic programming and have attempted solve Problem 15 of Project Euler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.