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 Fascinating Number Calculator #1218

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/Fascinating-Number-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# <p align="center">Fascinating Number Calculator</p>

## Description :-

This is a simple web application that allows users to check if a given number is a fascinating number or not.
A fascinating number is a positive number which contains all the digits from 1 to 9 exactly once and does not contain any 0's
after Concatenating number(x) with the numbers 2 * x and 3 * x.

For example, the number 192 is fascinating because (192 * 2 = 384 and 192 * 3 = 576) and after concatenating it become (192384576) which contain all the digits from 1 to 9.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Features :-

- Users can input a number.
- Upon clicking the "Check for Fascinating" button, the application checks whether the entered number is a fascinating number or not.
- The result is displayed below the input field, indicating whether the number is fascinating or not.

## Screenshots :-

![image]()

![image]()

![image]()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Calculators/Fascinating-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">
<title>Fascinating Number Calculator</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<header>
<h1>Fascinating Number Checker Calculator</h1>
</header>
<main>
<div class="container">
<label for="no">Enter the Number between 100 to 999 : </label>
<input type="number" placeholder="Enter number(n)" class="number" required>
<button onclick="checkFascinating()">Check for Fascinating</button>
<h2 class="text"></h2>
<h3 class="showHow"></h3>

</div>
</main>
<script src="script.js"></script>
</body>

</html>
38 changes: 38 additions & 0 deletions Calculators/Fascinating-Number-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const checkFascinating = () => {
let n = document.querySelector(".number").value;
let txt = document.querySelector(".text");
let s = document.querySelector(".showHow");
if (n === "" || Number.isNaN(n) || n < 100 || n > 999) {
txt.textContent = ("Please enter a valid number between 100 and 999");
s.textContent = ``
}
else {
let n2 = 2 * n;
let n3 = 3 * n;
let newnum = '' + n + '' + n2 + '' + n3;
let result = newnum;
if (result.length > 9) {
txt.textContent = "${n} is not a Fascinating Number!";
s.textContent = ``
}
else {
result = result.split('').sort((a, b) => a - b).join('');
let flag = 0;
for (let i = 1; i <= 9; i++) {
if (result[i - 1] != i) {
flag = 1;
txt.textContent = `${n} is not a Fascinating Number!`;
s.textContent = `PROOF: n = ${n}, 2*n = ${2 * n}, 3*n = ${3 * n} and after concatenating n , 2*n , 3*n we get : ${newnum} which does not contain all the digit from 1 to 9`;

break;
}
}
if (flag == 0) {
txt.textContent = `${n} is a Fascinating Number!`;
s.textContent = `PROOF: n = ${n}, 2 * n = ${2 * n}, 3 * n = ${3 * n} and after concatenating n, 2*n, 3*n we get : ${newnum} which contain all the digit from 1 to 9`;

}
}
}

}
73 changes: 73 additions & 0 deletions Calculators/Fascinating-Number-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
body {
font-family: Arial, sans-serif;
background-color: rgb(255, 177, 255);
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-image: url('assets/background.jpeg');
background-size: cover;
background-position: center;
}

h1 {
color: rgb(0, 104, 145);
margin-bottom: 40px;
font-weight: bold;
}

h2 {
color: #e74fd8;
margin-bottom: 40px;
font-weight: bold;

}

h3 {
color: rgb(39, 38, 38);
margin-bottom: 40px;
font-weight: bold;
}


.container {
display: flex;
flex-direction: column;
color: rgb(0, 140, 195);
font-weight: bold;
font-size: larger;
align-items: center;
justify-content: center;
background: linear-gradient(to right, #f9cad3, #bee8ff);
border-radius: 30px;
padding: 100px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border: #379df6;

}

label {
margin-bottom: 20px;
}

input {
padding: 8px;
margin-bottom: 20px;
width: 150px;
border: #67adea
}

button {
padding: 10px;
background-color: rgb(84, 189, 231);
color: white;
border: none;
cursor: pointer;
font-size: medium;
}

button:hover {
background-color: #2797f9;
}
Loading