Problem 020

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.
JMW1994
Posts: 43
Joined: Sat Apr 09, 2011 11:35 pm

Re: Problem 020

Post by JMW1994 »

Allasar wrote: Not giving it away but think about school and how you learned to multiply in your head or by pen and paper. Now try to learn the computer to do it in the same way. For instance, when you were asked to do 28*56, you would do it step by step.
In math, the process of multiplying 28*56 would be:
28
*56
------
168
+1400
-------
1568
In this, you would ignore the entire number and just focus on the 8 and 6 and then focus on the 2 with the eight. And then you would deal with the 5 and do the process over again.

Basically I would have to individually multiply each number separately in order to store 100! appropriately. What Allasar is saying is that in order to store the number, you would have to, one-by-one, multiply number such as 100*99, then take that answer and multiply by 98, etc. Each multiplication could be stored in an array, but how would I somehow still get to the 100! answer. Or did I miss the point of his hint and I just went into circles?
Image
zombiekiller222
Posts: 2
Joined: Thu May 05, 2011 11:23 am

100% the answer is right.

Post by zombiekiller222 »

Problem 20. I'm 99.999999...% sure the answer I gave is right. Seriously, please check that it works. I gave 713 but it didn't work.
zombiekiller222
Posts: 2
Joined: Thu May 05, 2011 11:23 am

Re: 100% the answer is right.

Post by zombiekiller222 »

n! means n (n 1) ... 3 2 1

For example, 10! = 10 9 ... 3 2 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.

Find the sum of the digits in the number 100!
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: 100% the answer is right.

Post by Lord_Farin »

There is no integer n for which the sum of digits in n! equals 713. You may PM me your code, then I will look into it.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: 100% the answer is right.

Post by hk »

harryh wrote: This forum is a place for users to air their possible concerns or difficulties in understanding specific ProjectEuler problems.
It is not a forum to discuss solution methods or post spoilers. The proper place to discuss relevant algorithms, solution methods, proofs, results for higher limits etc is of course the thread of each problem which becomes accessible only after submitting the correct answer.
Before you start a new topic in this forum, please make sure that a topic for the same problem does not already exist.
If such a topic already exists, please post your question or concern in that topic; it's the only way to keep the number of topics manageable and make it possible to easily search for a specific problem.

If there is no previous topic for the specific problem you are trying to solve, you may start a new topic, giving as subject Problem xxx. Please do not use in the Subject-field expressions like "Clarification needed", "problem with the wording", "Correct answer not accepted" etc

Finally, please do not start topics about specific PE problems in other parts of this bulletin board; it is much easier for everyone to have all the relevant comments, questions etc. collected in one place, i.e. this forum.



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. In particular don't post any code fragments or results.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: 100% the answer is right.

Post by rayfil »

@zombiekiller222

You are relatively new to this forum. FYI, problem numbers under #100 are padded with leading 0's to make them 3-digit numbers for ease of listing and searching. Your post has been transfered to the proper Problem 020 topic. You may even find an answer to your dilemma by reading other posts in that topic.
When you assume something, you risk being wrong half the time.
xe3tec
Posts: 46
Joined: Thu May 05, 2011 8:52 am
Location: Vienna
Contact:

Re: 100% the answer is right.

Post by xe3tec »

zombiekiller222 wrote:Problem 20. I'm 99.999999...% sure the answer I gave is right. Seriously, please check that it works. I gave 713 but it didn't work.
The only thing that some can be sure of is that either the error lies in the user's code or in the understanding of the problem, but it never lies in the Project/Solution Check.

the simple reason for that: other users already solved it
ilyak1986
Posts: 1
Joined: Tue Jun 21, 2011 9:39 am

Re: Problem 020

Post by ilyak1986 »

Hmmm...okay, here's the thing...

This problem is identical in nature to problem 16 (same deal with a huge number that you need to store and add up digit by digit), yet while my code worked for problem 16, after it spit out the answer for problem 20, the checker rejected it.

Now I know it's against the rules to post my answer. Who would I PM with the number I got (and the code I wrote--it's in R), to double check things? Because I see no reason that it gave me the correct answer for 2^1000 and choked on factorial(100)
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 020

Post by Lord_Farin »

ilyak1986 wrote:Hmmm...okay, here's the thing...

This problem is identical in nature to problem 16 (same deal with a huge number that you need to store and add up digit by digit), yet while my code worked for problem 16, after it spit out the answer for problem 20, the checker rejected it.

Now I know it's against the rules to post my answer. Who would I PM with the number I got (and the code I wrote--it's in R), to double check things? Because I see no reason that it gave me the correct answer for 2^1000 and choked on factorial(100)
I am willing to take a look if your language is somewhat similar to C, C#, C++, Java, Haskell or PHP (which it almost always will be ;) )
Image
Tadziokaz
Posts: 2
Joined: Sat Jun 25, 2011 1:41 pm

Re: Problem 020

Post by Tadziokaz »

i geting 734 but i think 100% its correct answer... but dont match with Problem answer.
User avatar
Francky
Posts: 90
Joined: Sat May 07, 2011 3:49 pm
Location: South of France

Re: Problem 020

Post by Francky »

Tadziokaz wrote:i geting 734 but i think 100% its correct answer... but dont match with Problem answer.
But it's 100% incorrect, sorry.
ImageEntia non sunt multiplicanda praeter necessitatem
keynote
Posts: 4
Joined: Thu Nov 03, 2011 3:24 am

Re: Problem 020

Post by keynote »

i get a total of 594 and my code outputs this number,

8825374904604367065806429546114151728526056581355224541884526528
4271496990461542824062456772765182862536979208272237582511852109
16864000000000000000000000000

i started out with 100 then multiplied this by 2 all the way up to 99.

i was hoping someone here could clue me as to where i my code is failing.

thanks in advance.
User avatar
PurpleBlu3s
Posts: 75
Joined: Mon Sep 19, 2011 6:49 pm

Re: Problem 020

Post by PurpleBlu3s »

keynote wrote:i get a total of 594 and my code outputs this number,

8825374904604367065806429546114151728526056581355224541884526528
4271496990461542824062456772765182862536979208272237582511852109
16864000000000000000000000000

i started out with 100 then multiplied this by 2 all the way up to 99.

i was hoping someone here could clue me as to where i my code is failing.

thanks in advance.
That is not 100!
Image
keynote
Posts: 4
Joined: Thu Nov 03, 2011 3:24 am

Re: Problem 020

Post by keynote »

PurpleBlu3s wrote:
keynote wrote:i get a total of 594 and my code outputs this number,

8825374904604367065806429546114151728526056581355224541884526528
4271496990461542824062456772765182862536979208272237582511852109
16864000000000000000000000000

i started out with 100 then multiplied this by 2 all the way up to 99.

i was hoping someone here could clue me as to where i my code is failing.

thanks in advance.
That is not 100!
if it isn't, where did i go wrong?
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 020

Post by thundre »

keynote wrote: 8825374904604367065806429546114151728526056581355224541884526528
4271496990461542824062456772765182862536979208272237582511852109
16864000000000000000000000000

i started out with 100 then multiplied this by 2 all the way up to 99.

if it isn't, where did i go wrong?
Trying to factor that number, it has the correct powers of 2 and 5, but it is not a multiple of 3, 7, 11...
Image
keynote
Posts: 4
Joined: Thu Nov 03, 2011 3:24 am

Re: Problem 020

Post by keynote »

thundre wrote:
keynote wrote: 8825374904604367065806429546114151728526056581355224541884526528
4271496990461542824062456772765182862536979208272237582511852109
16864000000000000000000000000

i started out with 100 then multiplied this by 2 all the way up to 99.

if it isn't, where did i go wrong?
Trying to factor that number, it has the correct powers of 2 and 5, but it is not a multiple of 3, 7, 11...
hmmm. i've coded the problem in such a way that it starts out at 100 * 2 * 3 ... 99. is there someone who i could send my code and see where the fault lies? i modified the code and used it to solve problem 16, so i am at a loss at why it isn't working for this problem.

thanks.
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem 020

Post by rayfil »

You can probably debug it yourself if you use the tools which you have available. For example, use your calculator to get the size and the first few digits of n! and compare what your code is giving you for that n. With properly chosen values of n, you can zoom in rapidly to where your code starts being in error.
When you assume something, you risk being wrong half the time.
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 020

Post by thundre »

keynote wrote:hmmm. i've coded the problem in such a way that it starts out at 100 * 2 * 3 ... 99. is there someone who i could send my code and see where the fault lies? i modified the code and used it to solve problem 16, so i am at a loss at why it isn't working for this problem.

thanks.
I'm curious enough to have a look at code that correctly handles multiplication by 2 or 5 but screws up other primes. PM it to me and I'll look this weekend. I know Java, C, Perl..
Image
keynote
Posts: 4
Joined: Thu Nov 03, 2011 3:24 am

Re: Problem 020

Post by keynote »

thundre wrote:
keynote wrote:hmmm. i've coded the problem in such a way that it starts out at 100 * 2 * 3 ... 99. is there someone who i could send my code and see where the fault lies? i modified the code and used it to solve problem 16, so i am at a loss at why it isn't working for this problem.

thanks.
I'm curious enough to have a look at code that correctly handles multiplication by 2 or 5 but screws up other primes. PM it to me and I'll look this weekend. I know Java, C, Perl..
pm sent. thanks.
whakamaru
Posts: 47
Joined: Thu May 06, 2010 11:08 pm

Re: Problem 020

Post by whakamaru »

After a big struggle I managed to get my 16-bit MS-debug programme to go. It is all of 75 bytes long, 17 for preparation, 26 for the multiplication, 9 to add, and another 23 to display the answer. Even the text is shorter than some of high-level languages!
Now I'm curious to know the size of the executable file compiled by high-level languages, C, Ruby, etc, especially the APL/J one...and also the 32-bit solution. :shock:
Last edited by whakamaru on Mon Nov 21, 2011 8:33 pm, edited 1 time in total.
Post Reply