Problem 001

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.
Post Reply
yth
Posts: 3
Joined: Tue Jul 29, 2014 12:01 am

Re: Problem 001

Post by yth »

The pdf file that had been mentioned a few times before seems to have been removed. Does any one know if there is another copy of it somewhere else?

I solve this problem, but my solution is the uninspired O(n) solution. I would really appreciate it if someone could give me some hints about the O(1) solution.
pieppiep
Posts: 23
Joined: Thu Dec 30, 2010 6:23 am

Re: Problem 001

Post by pieppiep »

One message says it is on the 'problems overview page'.
My guess is that is a page you can see when you're logged in and where that pdf-link is only visible when you've solved it.
So when the login function will be enabled again you can view the pdf.
Image
Svartskägg
Posts: 55
Joined: Thu Mar 29, 2012 12:55 pm
Location: Sweden

Re: Problem 001

Post by Svartskägg »

yth wrote:I solve this problem, but my solution is the uninspired O(n) solution. I would really appreciate it if someone could give me some hints about the O(1) solution.
Can you calculate the sum of all natural numbers below n with a faster than O(n) algorithm?
Image
320641_5486fc18ea1dcc4e9a8f29c7677a5c19 <-- my friend key
medicineman25
Posts: 2
Joined: Sat Apr 30, 2016 3:35 am

Alternative solution to problem 1

Post by medicineman25 »

Hi guys,

First post here, really happy to find this project. I hope I can contribute some constructive work.

Also, I apologise if this is the incorrect forum for such a post. Please direct me to the appropriate sub, should that be the case.

Ok, I disagree with the supposed answers to question 1. I find that it is simply incorrect. <spoiler removed by moderator>

I don't disagree that modulo should return the correct answer, by all rights it should.

However, I opted for a mathematical approach and returned a completely different answer, in the range of 30,000 +/- a few. After reviewing my code numerous times, I became rather perturbed and proceeded to manually input multiples of 3 and 5 under 1000, into a hand calculator (and had two other people do the same), until I reached the exact same answer I had previously returned with my code. Then I decided it was high time to check my answer against the agreed correct one and found that I was indeed off by no less than 20,000. Quite a difference.

Though this may seem unnecessary, let me first explain my logical path to my solution:

<spoiler removed by moderator>
User avatar
sjhillier
Administrator
Posts: 561
Joined: Sun Aug 17, 2014 4:59 pm
Location: Birmingham, UK
Contact:

Re: Alternative solution to problem 1

Post by sjhillier »

Always good to have new people. To answer one of the questions about where to post discussions of solved problems, I'm afraid this is not the right place, but given that this is problem 1, and you're just starting I expect, that's not such a big issue. If you look at the list of problems now you have solved problem 1, you will see some extra links available to you. One of these is a link to a thread hosting a discussion of the problem. There is a good place to post thoughts on the problem, and discover other peoples solutions. Another link (with a pdf symbol) will take you to a summary of solutions to the problem which I think will be of great help to you in answering your worries above. Though I haven't looked at your solution in detail, I suspect you'll find when you read there that while you've gone a long way to finding one of the more optimal solutions, there's a key point you've missed.
medicineman25
Posts: 2
Joined: Sat Apr 30, 2016 3:35 am

Re: Alternative solution to problem 1

Post by medicineman25 »

@sjhillier. Hey, thanks I'll have a look at those links and re-post. Yes, I feel as though I am missing something fundamental to the question here. It is most likely something bleedingly obvious, as is usually the case haha.
User avatar
sjhillier
Administrator
Posts: 561
Joined: Sun Aug 17, 2014 4:59 pm
Location: Birmingham, UK
Contact:

Re: Alternative solution to problem 1

Post by sjhillier »

Good luck. Just to clarify, you have to be logged in to your account to see the extra links, and then go to the list of problems, starting at 1, and the links should appear on the right hand side of the list next to problem 1.

If you're still having problems, try posting in the private forum for problem 1 and I'll try to look out for it and answer there to avoid spoilers here.
mafridi
Posts: 4
Joined: Mon Oct 22, 2018 7:24 pm

Re: Problem 001

Post by mafridi »

Hi, I solved the first problem using the brute force approach but I want to better understand the formula that was provided in the answer.

Can someone please use the formula to write out the solution to the sample they gave (If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.) and PM me the written out formula?

Thank you.
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 001

Post by hk »

Please read the provided pdf write-up on the main site. (click on the pdf-icon)
Hint: you can use the formula for the sum of an arithmetic sequence. https://en.wikipedia.org/wiki/Arithmetic_progression
Image
War ruins the life and health of untold numbers of innocent children.
mafridi
Posts: 4
Joined: Mon Oct 22, 2018 7:24 pm

Re: Problem 001

Post by mafridi »

hk wrote: Tue Oct 23, 2018 8:30 pm Please read the provided pdf write-up on the main site. (click on the pdf-icon)
Hint: you can use the formula for the sum of an arithmetic sequence. https://en.wikipedia.org/wiki/Arithmetic_progression
Thanks for your reply. I did initially read the PDF before posting my question but the Wiki link helped clarify it better for me. I'm not familiar with the math terms so didn't know what to search for online, but I'm learning through these exercises. :)
lad
Posts: 1
Joined: Fri Jan 21, 2022 11:40 pm

Problem 001 solution may be wrong

Post by lad »

To the authors of Problem 1:
please check your solution of Problem 1 with numbers below 16 generated by the
program used to get the solution of Problem 1
against a manual solution on a piece of paper.
I think the solution has to be 75, not 60.
60 looks like the result of a Python3 one-liner that I found elsewhere.
If I'm right, the solution of Problem 1 is higher than suggested.
L. Adam
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 1 solution may be wrong

Post by hk »

The numbers you should add are: 3,5,6,9,10,12,15.
Sum of these is 60.
The answer 75 looks like you are counting 15 twice.

Just a remark:
This probem has been on the site for 20 years and has been solved by 967644 people.
And wouldn't it be strange if we used a Python 3 oneliner to get the answer? The problem was published in 2001.
Python3 didn't exist as far back as 2001.
Image
War ruins the life and health of untold numbers of innocent children.
mujie
Posts: 1
Joined: Thu Sep 29, 2022 9:38 am

Re: Problem 001

Post by mujie »

I have no idea how to get started. Do I need to use python or something?
skoczian
Posts: 28
Joined: Sat May 25, 2013 4:43 pm

Re: Problem 001

Post by skoczian »

mujie wrote: Thu Sep 29, 2022 9:39 am I have no idea how to get started. Do I need to use python or something?
For this problem you don't need Python or any other programming language. Just a bit of pretty easy mathematics.

I have found it very helpful to read the thread in this forum for any problem I want to solve. Even if everybody follows the rules in the big red box possible misunderstandings of the problem text are cleared up. And quite often you get hints as to useful search terms, if the mathematics isn't clear to you from the start.

So I'd read this thread carefully. It does contain help.

Among the first problems there are many solvable without programming. If code is needed, Python is quite a good choice, but any programming language should work.
Post Reply