Amazon Interview Preparation: Project Euler (Problem 1)

#Programming   #projecteuler   #Python   #aws  
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:

1.jpeg

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

2.jpeg

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

3.jpeg

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

4.jpeg

Then lastly we want to print all those numbers.

5.jpeg

Our total will be: 233168

6.jpeg

7.jpeg

Start blogging about your favorite technologies and get more readers

Join other developers and claim your FAUN account now!

Avatar

The Maths Geek 🤓

@thenjikubheka
Mathematician | Software Engineer | Amazonian| Open Source | Blogger | Ban Killer Robots
68

Authority

4800

Total Hits