Problem 080

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you
are requested to be thoughtful in not posting anything
that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
incandenza
Posts: 7
Joined: Wed Apr 02, 2008 9:00 pm

Problem 080

Post by incandenza »

Could someone clarify this one for me? I must be missing something.

Here is sqrt(2) to 105 digits (put a linebreak in so the forum wouldn't cut it off):

1.41421356237309504880168872420969807856967187537694
8073176679737990732478462107038850387534327641572735014

It seems to me that the first 100 decimal digits are '4142 ... 5727', but the sum of these is 481, not 475 as stated in the example.

Maybe I'm supposed to count the integer part as one of the digits, taking one digit off the end? Then the example works, but I still don't get the right answer overall.

Thanks for any clarification.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Clarification on problem 80

Post by stijn263 »

also include the 1
incandenza
Posts: 7
Joined: Wed Apr 02, 2008 9:00 pm

Re: Clarification on problem 80

Post by incandenza »

Ah, thanks for the help, got it now.

Probably could've figured out that was what was meant, but I had another dumb mistake in there that threw me off.
jpowell
Posts: 2
Joined: Wed Sep 24, 2008 10:45 pm

Re: Clarification on problem 80

Post by jpowell »

I'm having a few problems with this one. As far as I can tell there are 90 irrational numbers, and for each of those I need to add 100 digits to the running total.

The first number is 1414....1572, the final is 9949....1952.

The answer I get isn't correct, any suggestions?
incandenza
Posts: 7
Joined: Wed Apr 02, 2008 9:00 pm

Re: Clarification on problem 80

Post by incandenza »

jpowell wrote:I'm having a few problems with this one. As far as I can tell there are 90 irrational numbers, and for each of those I need to add 100 digits to the running total.

The first number is 1414....1572, the final is 9949....1952.

The answer I get isn't correct, any suggestions?
All of the numbers you list match mine (including the total), so I don't know where your mistake might be.
jpowell
Posts: 2
Joined: Wed Sep 24, 2008 10:45 pm

Re: Clarification on problem 80

Post by jpowell »

I have PMed you with my (wrong) answer. If you are willing, I could also send the python code I am using.
User avatar
GoSlow2GoFast
Posts: 11
Joined: Fri Nov 07, 2008 3:31 am

Problem 80

Post by GoSlow2GoFast »

I don't understand the how you came up with a sum of the 100 decimal digits of sqrt(2) of 475? I have used "bc" and a different calculator to confirm my digit string and I come up with a digit sum of 481. Below is my sqrt(2) calced to 100 decimal places, is this wrong?

1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727

~gs2gf
TripleM
Posts: 382
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 80

Post by TripleM »

GoSlow2GoFast wrote:...sum of the 100 decimal digits...
GoSlow2GoFast wrote:...calced to 100 decimal places...
Note the key different word.
User avatar
DNS
Posts: 30
Joined: Thu Oct 16, 2008 9:32 am
Location: Ukraine, Nikolaev

Re: Problem 80

Post by DNS »

TripleM is right!
But I first time did the same and had the same mistake.
gs2gf, sum is 1+4+1+4+2+... (100 digits)
sqrt(2) is right, but the last (100th) digit should be rounded
2 x 2 = 4 = true
User avatar
GoSlow2GoFast
Posts: 11
Joined: Fri Nov 07, 2008 3:31 am

Re: Problem 80

Post by GoSlow2GoFast »

I see my mistake now, thought I had tried this but guess not. I was reading "100 decimal digits" to mean everything to the RIGHT of the decimal place. I see now that euler intended it to be 100 digits including those to the LEFT of the decimal place as well.

I was on board that rounding may be an issue, but in the case of sqrt(2) I knew that would only mean a difference of at most 1 between my result and the problem's given sum. So I knew it was more than that.

Thanks all,
~gs2gf
User avatar
GoSlow2GoFast
Posts: 11
Joined: Fri Nov 07, 2008 3:31 am

Re: Problem 80

Post by GoSlow2GoFast »

DNS wrote:... but the last (100th) digit should be rounded
I'm not seeing the rounding. If I look at the example in the problem statement, it says the sum of the first 100 decimal digitas should be 475. When I generate the sqrt(2), here are the first 100 digits I get, which do indeed sum to 475.

1414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572

However, if I go out one more position, the next digit (101) would be a "7". If rounding were being used then this would change the first 100 to be:

1414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573

But that sums to 476. Based on that it doesn't seem like rounding is in play. Or am I missing something?

~gs2gf
TripleM
Posts: 382
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 80

Post by TripleM »

No, you shouldn't be rounding, what you have is fine. Yeah, I think I wasn't sure whether it meant to include the first digit or not when I solved it, but the example clarified it enough for me.
hrishikesh
Posts: 3
Joined: Sat Dec 20, 2008 5:27 am
Location: India

Problem 80 Trouble

Post by hrishikesh »

Euler Problem 80
It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all.

The square root of two is 1.41421356237309504880..., and the digital sum of the first one hundred decimal digits is 475.

For the first one hundred natural numbers, find the total of the digital sums of the first one hundred decimal digits for all the irrational square roots.
I have written this mathematica code:

Code: Select all

snip
I have checked the code and entered the answer hundreds of times without success. Can someone tell me what am I doing wrong?

Here are some results generated by my program:

2:

Code: Select all

{1,4,1,4,2,1,3,5,6,2,3,7,3,0,9,5,0,4,8,8,0,1,6,8,8,7,2,4,2,0,9,6,9,8,\
0,7,8,5,6,9,6,7,1,8,7,5,3,7,6,9,4,8,0,7,3,1,7,6,6,7,9,7,3,7,9,9,0,7,3,\
2,4,7,8,4,6,2,1,0,7,0,3,8,8,5,0,3,8,7,5,3,4,3,2,7,6,4,1,5,7,2}

sum=475
3:

Code: Select all

{1,7,3,2,0,5,0,8,0,7,5,6,8,8,7,7,2,9,3,5,2,7,4,4,6,3,4,1,5,0,5,8,7,2,\
3,6,6,9,4,2,8,0,5,2,5,3,8,1,0,3,8,0,6,2,8,0,5,5,8,0,6,9,7,9,4,5,1,9,3,\
3,0,1,6,9,0,8,8,0,0,0,3,7,0,8,1,1,4,6,1,8,6,7,5,7,2,4,8,5,7,5}

sum=441
37:

Code: Select all

{6,0,8,2,7,6,2,5,3,0,2,9,8,2,1,9,6,8,8,9,9,9,6,8,4,2,4,5,2,0,2,0,6,7,\
0,6,2,0,8,4,9,7,0,0,9,4,7,8,6,4,1,1,1,8,6,4,1,9,1,5,3,0,4,6,4,8,6,3,3,\
2,7,2,5,3,1,8,9,1,0,2,3,9,8,0,3,0,6,6,4,2,7,9,5,7,8,4,8,6,6,3}

sum=457
99:

Code: Select all

{9,9,4,9,8,7,4,3,7,1,0,6,6,1,9,9,5,4,7,3,4,4,7,9,8,2,1,0,0,1,2,0,6,0,\
0,5,1,7,8,1,2,6,5,6,3,6,7,6,8,0,6,0,7,9,1,1,7,6,0,4,6,4,3,8,3,4,9,4,5,\
3,9,2,7,8,2,7,1,3,1,5,4,0,1,2,6,5,3,0,1,9,7,3,8,4,8,7,1,9,5,3}

sum=447
Last edited by rayfil on Sat Dec 20, 2008 5:56 am, edited 1 time in total.
Reason: It is preferable not to post code in this forum
User avatar
rayfil
Administrator
Posts: 1406
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 80 Trouble

Post by rayfil »

You (and I) probably don't know with certainty if the square root function you are using returns a truncated value or a rounded value.

The first thing I would do to find out would be to write a short program to return the square root of 99 (for example) with 5, 6, ..., 12 decimal places and confirm if truncated or rounded.
When you assume something, you risk being wrong half the time.
hrishikesh
Posts: 3
Joined: Sat Dec 20, 2008 5:27 am
Location: India

Re: Problem 80 Trouble

Post by hrishikesh »

Wow! Thanks for the suggestion. The problem turned out to be that mathematica sometimes rounded the fraction and sometimes it didn't :? . I calculated first 102 decimals and deleted last 2 decimals to get around this problem.
Thanks again :wink:
ouid
Posts: 2
Joined: Mon Aug 10, 2009 9:33 am

Re: Problem 080

Post by ouid »

Sorry for very dumb question, but in this problem what exactrly Natural Numbers are? N+ (1,2,3,4,...) or N0 (0,1,2,3,...)?
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 080

Post by daniel.is.fischer »

ouid wrote:Sorry for very dumb question, but in this problem what exactly Natural Numbers are? N+ (1,2,3,4,...) or N0 (0,1,2,3,...)?
Not dumb at all. In my experience, among mathematicians, the majority includes 0 among the natural numbers, but those that don't are far from a negligible minority.
Fortunately, for this problem, it doesn't matter which is your preferred definition of natural numbers, since both 0 and 100 have rational (hence integer) square roots, so the answer will be the same regardless of whether you consider the first 100 natural numbers to be 0-99 or 1-100 8-)
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
Eigen20
Posts: 1
Joined: Wed Aug 18, 2010 12:06 am

Re: Problem 080

Post by Eigen20 »

The wording of this problem is very weak.

It states, "For the first one hundred natural numbers, find the total of the digital sums of the first one hundred decimal digits for all the irrational square roots."

Key word, I would've thought, being decimal. But I have just reached the solution and I will clarify what it wants a little bit:

For numbers that are not perfect squares, it wants the sum of the first one hundred digits of each square root, including the integer "handle", and not including the 100th decimal digit. You can confirm this by searching for "square root 2" on the internet and checking the first 100 decimal digits and finding that they sum to 481, with the 100th digit being a 7 (making it obvious that 481 - 7 + 1 gives you a sum of 475, in agreement with PE, for the first 100 digits overall).

But here's the part that I think makes it REALLY weak: for perfect squares, it wants 0. Therefore, it wants your sum to include 1 + 4 + 1 + 4 + ... for root(2) = 1.414..., but it wants it to ignore 1 + 0 + 0 + ... for root(1) = 1.000.... I mean, if you want the handles for the irrational roots, why not the handles for integer roots too??

As for other advice, all I will say is, be careful with precision, truncation, and rounding.
TripleM
Posts: 382
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 080

Post by TripleM »

I'm afraid the wording isn't really that weak.

The definition of decimal digit is a digit between 0 and 9, inclusive. If you can find another definition that only includes digits after the decimal point, feel free to share it ;) If there was any doubt as to what you thought the definition was, the example should remove all doubt.

As for your second point, the problem clearly says 'for all the irrational square roots.'.
User avatar
PurpleBlu3s
Posts: 75
Joined: Mon Sep 19, 2011 6:49 pm

Re: Problem 080

Post by PurpleBlu3s »

I am getting the answer wrong, but I'm not sure why. I get 475 for sqrt 2 as in the example. Can anyone confirm these values?

sqrt 3 => 441
sqrt 5 => 423
sqrt 50 => 465
sqrt 99 => 446

Thanks.
Image
Post Reply