Join us

Amazon Interview Preparation: Project Euler (Problem 1)

Screen Shot 2021-10-20 at 8.40.10 PM.png

When preparing for a Technical interview with one of The Big Tech Companies; Amazon, Google, Facebook, Netflix, Microsoft, it’s vital to practice with resources such as Project Euler.

Project Euler is a series of challenging mathematical and computer programming problems that require more than just mathematical insights to solve.

Now let’s start with our first task, which can be solved using the language of your choice, I will be using Python.

Task 1: Multiples of 3 or 5

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. Find the sum of all the multiples of 3 or 5 below 1000.

Solution:

So the question is asking us to add all the natural numbers(values that are divisible by 3 or 5 and have no remainders).

Our range is 1 to 1000.

Let’s create a variable called sum:

Then create a For loop, and include the range function to count from 0 to 1000.

Then we have our conditional statement that will check for numbers divisible by 3 or 5.

Then we want to increment the sum, which is all the multiples of 3 and 5, from 0 to 1000.

Then lastly we want to print all those numbers.

Our total will be: 233168


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!

Avatar

The Maths Geek 🤓

@thenjikubheka
Mathematician | Software Engineer | Amazonian| Open Source | Blogger | Ban Killer Robots
User Popularity
328

Influence

32k

Total Hits

22

Posts