Skip to content
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

Added Niven Number Calculator #1067

Closed
wants to merge 12 commits into from
Closed
15 changes: 0 additions & 15 deletions Calculators/BMR-Calculator/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions Calculators/BMR-Calculator/index.html

This file was deleted.

61 changes: 0 additions & 61 deletions Calculators/BMR-Calculator/style.css

This file was deleted.

18 changes: 0 additions & 18 deletions Calculators/Kaprekar-Number-Calculator/README.md

This file was deleted.

18 changes: 18 additions & 0 deletions Calculators/Niven-Number-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# <p align="center">Niven Number Calculator</p>

## Description :-

A simple web-based calculator to find whether the number is Niven number or not.
Number logic:A number that is divisible by the sum of its digits is called a Niven number.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![Screenshot 2024-06-01 203757](https://github.com/Nayanika1402/CalcDiverse/assets/132455412/f21e3eaf-945f-4f70-a853-144e58e5b670)

![Screenshot 2024-06-01 203808](https://github.com/Nayanika1402/CalcDiverse/assets/132455412/d8a0c461-53cd-4fc9-a99f-5d0e8e34e668)
18 changes: 18 additions & 0 deletions Calculators/Niven-Number-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Niven Number Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Niven Number Calculator</h1>
<input type="number" id="numberInput" placeholder="Enter a number" />
<button onclick="checkNivenNumber()">Check</button>
<p id="result"></p>
</div>
<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions Calculators/Niven-Number-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function checkNivenNumber() {
const numberInput = document.getElementById('numberInput').value;
const resultElement = document.getElementById('result');

if (numberInput === '') {
resultElement.textContent = 'Please enter a number.';
return;
}

const number = parseInt(numberInput);
const sumOfDigits = number
.toString()
.split('')
.map(Number)
.reduce((acc, digit) => acc + digit, 0);

if (number % sumOfDigits === 0) {
resultElement.textContent = `${number} is a Niven number.`;
} else {
resultElement.textContent = `${number} is not a Niven number.`;
}
}
47 changes: 47 additions & 0 deletions Calculators/Niven-Number-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
background-image: linear-gradient(90deg, #1CA7EC, #1F2F98);
}

.container {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
}

input {
padding: 10px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

p {
margin-top: 20px;
font-size: 1.2em;
}
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ <h3>Given any number, it reaches to Four.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>BMR Calculator</h2>
<h3>Calculates the Basal Metabolic Rate of a person using Height,Weight & Age.</h3>
<div class="card-footer">
<a href="./Calculators/BMR-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/BMR-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Book Reading Time Calculator</h2>
Expand Down Expand Up @@ -1562,6 +1576,20 @@ <h3>Calculates the days remaining until the next birthday.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Niven Number Calculator</h2>
<h3>Checks whether the number is Niven number or not.</h3>
<div class="card-footer">
<a href="./Calculators/Niven-Number-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Niven-Number-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Number Of Days Calculator</h2>
Expand Down