Page 8 of 8
Re: Problem 001
Posted: Tue Jul 29, 2014 12:04 am
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.
Re: Problem 001
Posted: Tue Jul 29, 2014 7:05 am
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.
Re: Problem 001
Posted: Tue Jul 29, 2014 3:44 pm
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?
Alternative solution to problem 1
Posted: Sat Apr 30, 2016 4:58 am
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>
Re: Alternative solution to problem 1
Posted: Sat Apr 30, 2016 9:58 am
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.
Re: Alternative solution to problem 1
Posted: Sat Apr 30, 2016 10:14 am
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.
Re: Alternative solution to problem 1
Posted: Sat Apr 30, 2016 10:22 am
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.
Re: Problem 001
Posted: Tue Oct 23, 2018 8:27 pm
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.
Re: Problem 001
Posted: Tue Oct 23, 2018 8:30 pm
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
Re: Problem 001
Posted: Wed Oct 24, 2018 2:53 pm
by mafridi
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.

Problem 001 solution may be wrong
Posted: Sat Jan 22, 2022 12:02 am
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
Re: Problem 1 solution may be wrong
Posted: Sat Jan 22, 2022 12:54 pm
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.
Re: Problem 001
Posted: Thu Sep 29, 2022 9:39 am
by mujie
I have no idea how to get started. Do I need to use python or something?
Re: Problem 001
Posted: Fri Sep 30, 2022 7:55 pm
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.