forked from pranjay-poddar/Dev-Geeks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01a8134
commit aed4923
Showing
3 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Spy Number Checker</title> | ||
<link rel="stylesheet" href="./style.css"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<header> | ||
<h1>Spy Number Checker</h1> | ||
<p>Enter any number here to know whether it is Spy Number or not!!</p> | ||
</header> | ||
<div class="inputs"> | ||
<input type="number" spellcheck="false" placeholder="Enter any number"> | ||
<button>Check Spy </button> | ||
</div> | ||
<p class="info-txt"></p> | ||
</div> | ||
<script src="./script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const txtInput = document.querySelector(".inputs input"), | ||
checkBtn = document.querySelector(".inputs button"), | ||
infoTxt = document.querySelector(".info-txt"); | ||
let filterInput; | ||
|
||
|
||
// javascript program to check if x is a perfect square | ||
|
||
// A utility function that returns true if x is perfect square | ||
function isPerfectSquare( x) | ||
{ | ||
let s = parseInt(Math.sqrt(x)); | ||
return (s * s == x); | ||
} | ||
|
||
// Returns true if n is a Fibonacci Number, else false | ||
function isFibonacci( n) | ||
{ | ||
|
||
// n is Fibonacci if one of 5*n*n + 4 or 5*n*n - 4 or both | ||
// is a perfect square | ||
return isPerfectSquare(5 * n * n + 4) || | ||
isPerfectSquare(5 * n * n - 4); | ||
} | ||
function spy(value) { | ||
|
||
sum = 0; | ||
prod=1; | ||
|
||
while (value) { | ||
sum += value % 10; | ||
prod=prod*value%10; | ||
value = Math.floor(value / 10); | ||
} | ||
return (sum==prod); | ||
} | ||
// A utility function to test above functions | ||
function isString(value) { | ||
return typeof value === 'string' || value instanceof String; | ||
} | ||
|
||
|
||
|
||
checkBtn.addEventListener("click", () => { | ||
let n = filterInput; | ||
console.log(typeof n); | ||
|
||
console.log(isFibonacci(n)); | ||
infoTxt.style.display = "block"; | ||
// if(isString(n)===true){ | ||
// return infoTxt.innerHTML = `Enter a valid input` | ||
// } | ||
// else{ | ||
if(spy(n)===true) { | ||
return infoTxt.innerHTML = `Yes, <span>'${txtInput.value}'</span> is Spy number`; | ||
} | ||
infoTxt.innerHTML = `NO, <span>'${txtInput.value}'</span> is not a Spy number`; | ||
|
||
}); | ||
|
||
txtInput.addEventListener("keyup", () => { | ||
filterInput = txtInput.value.toLowerCase().replace(/[^A-Z0-9]/ig, ""); | ||
if(filterInput) { | ||
return checkBtn.classList.add("active"); | ||
} | ||
infoTxt.style.display = "none"; | ||
checkBtn.classList.remove("active"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap'); | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: 'Poppins', sans-serif; | ||
} | ||
body{ | ||
display: flex; | ||
padding: 0 10px; | ||
background: #090222; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
/* background: #AA57CC; */ | ||
margin-top: 200px; | ||
overflow: hidden; | ||
|
||
} | ||
::selection{ | ||
color: #fff; | ||
background: rgb(170,87,204,0.8); | ||
} | ||
.wrapper{ | ||
max-width: 500px; | ||
background: #fff; | ||
border-radius: 7px; | ||
padding: 20px 25px 15px; | ||
box-shadow: 0 15px 40px rgba(0,0,0,0.12); | ||
margin-block-end: auto; | ||
|
||
} | ||
header h1{ | ||
font-size: 27px; | ||
font-weight: 500; | ||
text-align: center; | ||
} | ||
header p{ | ||
margin-top: 5px; | ||
font-size: 18px; | ||
color: #474747; | ||
} | ||
.inputs{ | ||
margin: 20px 0 27px; | ||
} | ||
.inputs input{ | ||
width: 100%; | ||
height: 60px; | ||
outline: none; | ||
padding: 0 17px; | ||
font-size: 19px; | ||
border-radius: 5px; | ||
border: 1px solid #999; | ||
transition: 0.1s ease; | ||
} | ||
.inputs input::placeholder{ | ||
color: #999999; | ||
} | ||
.inputs input:focus{ | ||
box-shadow: 0 3px 6px rgba(0,0,0,0.13); | ||
} | ||
.inputs input:focus::placeholder{ | ||
color: #bebebe; | ||
} | ||
.inputs button{ | ||
width: 100%; | ||
height: 56px; | ||
border: none; | ||
opacity: 0.7; | ||
outline: none; | ||
color: #fff; | ||
cursor: pointer; | ||
font-size: 17px; | ||
margin-top: 20px; | ||
border-radius: 5px; | ||
pointer-events: none; | ||
transition: opacity 0.15s ease; | ||
background: #090221; | ||
} | ||
.inputs button.active{ | ||
opacity: 1; | ||
pointer-events: auto; | ||
} | ||
.info-txt{ | ||
display: none; | ||
font-size: 19px; | ||
text-align: center; | ||
margin-bottom: 18px; | ||
} | ||
.info-txt span{ | ||
color: #AA57CC; | ||
} | ||
|
||
@media (max-width: 520px) { | ||
.wrapper{ | ||
padding: 17px 20px 10px; | ||
} | ||
header h1{ | ||
font-size: 25px; | ||
} | ||
header p{ | ||
font-size: 16px; | ||
} | ||
.inputs input{ | ||
height: 54px; | ||
font-size: 17px; | ||
} | ||
.inputs button{ | ||
height: 50px; | ||
font-size: 16px; | ||
margin-top: 17px; | ||
} | ||
.info-txt{ | ||
font-size: 18px; | ||
} | ||
} |