Project Euler 1
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 - 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 && %5)[0->1000] = Σ(%3)[0->1000] + Σ(%5)[0->1000] - Σ(%3 && %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 && %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 && %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);
Developer | Yoann Nouveau |
Username | YoannN2 |
Uploaded | September 08, 2022 |
Rating | 3 |
Size | 2,353 Kb |
Views | 28,336 |
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!
Name | Size |
Material Design Ripple effect on buttons | 3,261 Kb |
Formulaire HTML | 3,809 Kb |
Test | 2,380 Kb |
PongJS | 5,461 Kb |
Checkbox jQuery | 2,445 Kb |
Tooltips | 3,983 Kb |
Playing around with sheperd | 7,414 Kb |
User Profile | 5,877 Kb |
WIP - Toggling password JS JQUERY ANGULAR VUEJS | 5,806 Kb |
Project Euler 7 | 2,142 Kb |
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!
Name | Username | Size |
Example SVGZ Data URI | Joeyhoer | 2,981 Kb |
Haml Calendar | Katydecorah | 5,643 Kb |
Automatic scroll | Skeurentjes | 4,042 Kb |
Navcube | Wbarlow | 4,775 Kb |
Elon Musk - Tribute Page - FreeCodeCamp | Yunnimun | 8,615 Kb |
Comment Jquery | SquishyAndroid | 2,421 Kb |
Two column of responsive height | Fixie | 2,908 Kb |
Buttons for autumn | Nikazawila | 1,795 Kb |
Large canvas mousemove experiment | Jibbon | 2,885 Kb |
Basic jQuery Filter list | Mtedwards | 2,464 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!