Project Euler 1

Developer
Size
2,353 Kb
Views
28,336

How do I make an project euler 1?

Since I did this by hand, I'm just writting it down (for consistency's sake, so that all my answers are here). What is a project euler 1? How do you make a project euler 1? This script and codes were developed by Yoann Nouveau on 08 September 2022, Thursday.

Project Euler 1 Previews

Project Euler 1 - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Project Euler 1</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Project Euler Q1</h1>
<p> Since I did this by hand, I'm just writting it down (for consistency's sake, so that all my answers are here)
</p>
<h2>The problem:</h2>
<p> Find the sum of all multiple of 3 or 5 between 0 and 1000.
</p>
<h3>Step #1</h3>
<p>Translating the question</p>
<p> Σ(%3 &amp;&amp; %5)[0->1000] = Σ(%3)[0->1000] + Σ(%5)[0->1000] - Σ(%3 &amp;&amp; %5)[0->1000]
</p>
<h3>Step #2</h3>
<p>Finding the sum of all multiples of 3 between 0 and 1000</p>
<p> Σ(%3)[0->1000] = 3x1 + 3x2 + 3x3 ... 3x333 <br/><span class="comment"> // 333*3=999, the largest multiple of 3 between 0 and 1000</span> <ul> <li>= 3x(1+2+3...+333)</li> <li>= 3x(333/2(333+1))</li> <li>= 3x 55611</li> <li>= 166833</li> </ul>
</p>
<h3>Step #3</h3>
<p>Finding the sum of all multiples of 5 between 0 and 1000</p>
<p> Σ(%5)[0->1000] = 5x1 + 5x2 + 5x3 ... 5x199 <span class="comment"> // 199*5=995, 1000 is excluded</span> <ul> <li>= 5x(1+2+3...+199)</li> <li>= 5x(199/2(199+1))</li> <li>= 5x 19900</li> <li>= 99500</li> </ul>
</p>
<h3>Step #4</h3>
<p>Finding the sum of all multiples of 3 and 5 between 0 and 1000</p>
<p> Σ(%3 &amp;&amp; %5)[0->1000] = 3x5x1 + 3x5x2 + 3x5x3 ... 3x5x66 <span class="comment"> // 3*5*66=990</span> <ul> <li>= 3x5x(1+2+3...+66)</li> <li>= 3x5x(66/2(66+1))</li> <li>= 3x5x 2211</li> <li>= 33165</li> </ul>
</p>
<h3>Final Step</h3>
<p>Solving the equation:</p>
<p> Σ(%3||%5)[0->1000] = Σ(%3)[0->1000] + Σ(%5)[0->1000] - Σ(%3 &amp;&amp; %5)[0->1000] <ul> <li>= 166833 + 99500 - 33165</li> <li>= 233168</li> </ul>
</p>
<h3>TL;DR</h3>
<pre>
function multipleOf(num){ var n = Math.floor(999/num); return = num*(n/2*(n+1));
}
var answer = multipleOf(3) + multipleOf(5) - multipleOf(3*5);
</pre> <script src="js/index.js"></script>
</body>
</html>

Project Euler 1 - Script Codes CSS Codes

li{ list-style:none;
}
.comment{ position:relative; left:50px; opacity:0.5;
}

Project Euler 1 - Script Codes JS Codes

function multipleOf(num){ var n = Math.floor(999/num); return num*(n/2*(n+1));
}
var answer = multipleOf(3) + multipleOf(5) - multipleOf(3*5);
console.log(answer);
Project Euler 1 - Script Codes
Project Euler 1 - Script Codes
Home Page Home
Developer Yoann Nouveau
Username YoannN2
Uploaded September 08, 2022
Rating 3
Size 2,353 Kb
Views 28,336
Do you need developer help for Project Euler 1?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Yoann Nouveau (YoannN2) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!