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 Special Number-2 Calculator #1566

Closed
Closed
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
29 changes: 29 additions & 0 deletions Calculators/Special-Number-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# <p align="center">Special Number Calculator</p>

## Description :-

This Calculator predicts whether the number that is being provided as input by the user is a Special Number or not.
A "special number" typically refers to a number with unique properties, but the definition can vary. For this example, let's consider a special number to be one whose sum of the factorial of digits equals the number itself.
For example, 145 is a special number because 1! + 4! + 5! = 145

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

### On search

![ss-1](https://github.com/Rakesh9100/CalcDiverse/assets/135226069/438728f7-04b0-40f0-9d36-af4caaa6dc86)

### These are the UI for the page, The added background-size and animation properties to create a smooth, animated gradient background that transitions between four different colors.

![ss-2](https://github.com/Rakesh9100/CalcDiverse/assets/135226069/c1545344-30b8-458a-8339-e02605c3dc7b)
![ss-3](https://github.com/Rakesh9100/CalcDiverse/assets/135226069/80b76b33-4c4d-40f7-910e-72bf6ef35633)
![ss-4](https://github.com/Rakesh9100/CalcDiverse/assets/135226069/90c362ea-d7fa-422f-9fa3-b9055e3bb5db)

### Sample Output,

![ss-5](https://github.com/Rakesh9100/CalcDiverse/assets/135226069/17e9cd55-5c3d-4b55-a9e2-73abd022519d)
28 changes: 28 additions & 0 deletions Calculators/Special-Number-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Special Number Calculator</title>
</head>
<body>
<div class="container">
<h1>Special Number Calculator</h1>
<form id="specialNumberForm" class="form-group">
<div class="form-control">
<label for="number">Enter a Number:</label>
<input type="number" id="number" min="0" required />
</div>
<button type="button" class="btn" onclick="checkSpecialNumber()">
Check
</button>
</form>
<div id="result" class="result" style="display: none">
<h2>Result:</h2>
<p id="resultMessage"></p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions Calculators/Special-Number-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function factorial(n) {
if (n === 0 || n === 1) return 1;
return n * factorial(n - 1);
}

function checkSpecialNumber() {
const number = document.getElementById("number").value;
const digits = number.split("");
let sum = 0;

for (let digit of digits) {
sum += factorial(parseInt(digit));
}

const resultElement = document.getElementById("result");
const resultMessage = document.getElementById("resultMessage");

if (sum == number) {
resultMessage.textContent = `${number} is a special number!`;
resultMessage.style.color = "white";
} else {
resultMessage.textContent = `${number} is not a special number.`;
resultMessage.style.color = "white";
}

resultElement.style.display = "block";
}
153 changes: 153 additions & 0 deletions Calculators/Special-Number-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
body,
h1,
h2,
p,
form,
label,
input,
button,
div {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: "Arial", sans-serif;
background: linear-gradient(-45deg, #6a11cb, #236ae4, #ff5f5f, #ffc371);
background-size: 400% 400%;
animation: gradientAnimation 15s ease infinite;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #fff;
}

@keyframes gradientAnimation {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

.container {
background: rgba(255, 255, 255, 0.1);
padding: 40px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
border-radius: 10px;
max-width: 500px;
width: 100%;
text-align: center;
backdrop-filter: blur(10px);
}

h1 {
margin-bottom: 20px;
font-size: 32px;
color: #fff;
}

.form-group {
margin-bottom: 20px;
}

.form-control {
margin-bottom: 15px;
text-align: left;
}

label {
display: block;
margin-bottom: 5px;
color: #e0e0e0;
font-weight: bold;
}

input {
width: 100%;
padding: 12px;
border: none;
border-radius: 5px;
font-size: 16px;
margin-bottom: 10px;
background: rgba(255, 255, 255, 0.2);
color: #fff;
outline: none;
}

input::placeholder {
color: #e0e0e0;
}

input:focus {
border: 2px solid #2575fc;
background: rgba(255, 255, 255, 0.3);
}

.btn {
padding: 12px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
background: linear-gradient(-45deg, #ff5f6d, #ffc371, #9911cb, #2575fc);
background-size: 400% 400%;
animation: buttonGradientAnimation 10s ease infinite;
color: #fff;
}

@keyframes buttonGradientAnimation {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

.btn:hover {
opacity: 0.9;
}

.result {
margin-top: 20px;
padding: 20px;
background: rgba(0, 0, 0, 0.3);
border-radius: 10px;
}

.result h2 {
font-size: 24px;
margin-bottom: 10px;
color: #fff;
}

.result p {
font-size: 22px;
color: #ffc371;
}

@media (max-width: 600px) {
.container {
padding: 20px;
}

h1 {
font-size: 24px;
}

.btn {
padding: 10px 15px;
font-size: 14px;
}
}
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3697,6 +3697,21 @@ <h3>Calculator to combine two sound levels in decibels (dB).</h3>
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Sound-Level-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>Special Number Calculator</h2>
<h3>Checks whether the input number is a Special Number or not.</h3>
<div class="card-footer">
<a href="./Calculators/Special-Number-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Special-Number-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
Expand Down