Skip to content

JavascriptTask #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MultiOfThreeAndFive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function MultipleOfInt(){
//Find the sum of all the multiples of 3 or 5 below 1000.
var no=Number(document.getElementById("numMul").value);
var sum = 0;
for (var i = 0; i < no; i++) {
if (i % 3 === 0 || i % 5 === 0) {
sum += i;
}
}
document.getElementById("mulSet").value= sum;
console.log('Sum: %d', sum);
}
17 changes: 17 additions & 0 deletions MultipleBuzFiz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function multiplesFizBuz(){
var sum;
var no=Number(document.getElementById("numMul").value);
for (var x=1; x <= no; x++){
if( x % 3 && x % 5 ) {
console.log(x);
} else {
if( x % 3 == 0 ) {
console.log("buzz");
}
if( x % 5 == 0 ) {
console.log("fizz");
}
}

}
}
19 changes: 19 additions & 0 deletions MultiplethreeBuz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>

<head>
<title>sum of all the multiples of 3 or 5 below 1000 </title>

<style>

</style>

</head>
<body>
sum of all the multiples of 3 or 5 below 1000: <input type="number" id="numMul" value=10>
<button onclick="multiplesFizBuz()">Multiply</button></br>
<input id="mulSet" size="95">
<script type="text/javascript" src="MultipleBuzFiz.js"></script>
</body>

</html>
13 changes: 13 additions & 0 deletions SumofAnyNo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

function sumofInt(){
//sum of first 500 natural numbers
var no=Number(document.getElementById("num").value);
var num, sum = 0;

for (num = 1; num < no; num++)
{
sum = sum + num;
}
document.getElementById("fact").value= sum;
console.log("Sum = %4d\n", sum);
}
25 changes: 25 additions & 0 deletions factorial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html>

<head>
<title>Factorial </title>

<style>

</style>

</head>


<body>


Enter Number to factorial: <input id="num">
<button onclick="showFact()">Factorial</button>
<input id="fact">

<script type="text/javascript" src="FactorialOfNumber.js"></script>

</body>

</html>
19 changes: 19 additions & 0 deletions multi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>

<head>
<title>sum of all the multiples of 3 or 5 below 1000 </title>

<style>

</style>

</head>
<body>
sum of all the multiples of 3 or 5 below 1000: <input type="number" id="numMul" value=10>
<button onclick="MultipleOfInt()">Multiply</button>
<input id="mulSet">
<script type="text/javascript" src="MultiOfThreeAndFive.js"></script>
</body>

</html>
19 changes: 19 additions & 0 deletions sumof.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>

<head>
<title>sum of first 500 number </title>

<style>

</style>

</head>
<body>
sum of first 500 number: <input type="number" id="num">
<button onclick="sumofInt()">sum</button>
<input id="fact">
<script type="text/javascript" src="SumofAnyNo.js"></script>
</body>

</html>