diff --git a/Calculators/Neon-Number-Calculator/README.md b/Calculators/Neon-Number-Calculator/README.md new file mode 100644 index 000000000..324378a64 --- /dev/null +++ b/Calculators/Neon-Number-Calculator/README.md @@ -0,0 +1,25 @@ +#

Neon Number Calculator

+ +## Description: + +Neon Number Calculator is a web application that allows users to check if a given number is a neon number and find neon numbers within a specified range. + +- Checks if a number is a neon number. +- Finds neon numbers within a specified range. +- Responsive design for multiple devices. + +## What is a Neon Number? + +A neon number is a number where the sum of its digits, when squared, equals the original number. Mathematically, for a given number 'n', if the sum of the digits of n^2 is equal to n, then it is a neon number. + +For example, 9 is a neon number because 9^2 = 81, and the sum of the digits of 81 is 8 + 1 = 9. + +## Tech Stacks: + +- HTML +- CSS +- JavaScript + +## Screenshots: + +![Neon](https://github.com/Rakesh9100/CalcDiverse/assets/125949765/db79ecfe-1faa-4f01-9b63-f01f750a7781) diff --git a/Calculators/Neon-Number-Calculator/index.html b/Calculators/Neon-Number-Calculator/index.html new file mode 100644 index 000000000..360098536 --- /dev/null +++ b/Calculators/Neon-Number-Calculator/index.html @@ -0,0 +1,38 @@ + + + + + + + + Neon Number Calculator + + + + +

Neon Number Calculator

+ +
+
+

Check Single Neon Number

+ + + +

+
+ +
+

Check Neon Numbers in Range

+ + + + + +

+
+
+ + + + + diff --git a/Calculators/Neon-Number-Calculator/script.js b/Calculators/Neon-Number-Calculator/script.js new file mode 100644 index 000000000..4536f5f7e --- /dev/null +++ b/Calculators/Neon-Number-Calculator/script.js @@ -0,0 +1,50 @@ +function checkNeonNumber() { + let number = document.getElementById('number').value; + + if (!validateInput(number)) { + alert('Please enter a valid positive integer.'); + return; + } + + let result = isNeonNumber(number); + + document.getElementById('resultSingle').innerText = `${number} is ${result.isNeon ? '' : 'not '}a Neon number. ${result.explanation}`; +} + +function checkNeonNumbersInRange() { + let fromRange = parseInt(document.getElementById('fromRange').value); + let toRange = parseInt(document.getElementById('toRange').value); + + if (isNaN(fromRange) || isNaN(toRange) || fromRange >= toRange) { + alert('Please enter valid range values.'); + return; + } + + let neonNumbers = []; + + for (let i = fromRange; i <= toRange; i++) { + if (isNeonNumber(i.toString()).isNeon) { + neonNumbers.push(i); + } + } + + if (neonNumbers.length > 0) { + document.getElementById('rangeResult').innerText = `Neon numbers in the range ${fromRange} to ${toRange}: ${neonNumbers.join(', ')}`; + } else { + document.getElementById('rangeResult').innerText = `There are no Neon numbers in the range ${fromRange} to ${toRange}.`; + } +} + +function validateInput(number) { + return /^(0|[1-9]\d*)$/.test(number); +} + +function isNeonNumber(number) { + let square = parseInt(number) ** 2; + let digitSum = Array.from(square.toString()).reduce((acc, digit) => acc + parseInt(digit), 0); + + return { + isNeon: digitSum === parseInt(number), + explanation: `The square of ${number} is ${square}. The sum of its digits is ${digitSum}.` + }; +} diff --git a/Calculators/Neon-Number-Calculator/style.css b/Calculators/Neon-Number-Calculator/style.css new file mode 100644 index 000000000..60f978075 --- /dev/null +++ b/Calculators/Neon-Number-Calculator/style.css @@ -0,0 +1,79 @@ +body { + font-family: 'Arial', sans-serif; + text-align: center; + margin: 0; + padding: 0; + background-color: #000; + color: #fff; +} + +.calculator { + display: flex; + justify-content: space-around; + align-items: flex-start; /* Adjusted alignment */ + margin: 50px auto; + max-width: 900px; +} + +.section { + width: 45%; + padding: 20px; + box-sizing: border-box; + background-color: #000; + border: 1px solid #00f; + border-radius: 15px; + box-shadow: 0 0 20px rgba(0, 255, 255, 0.8); + margin-bottom: 20px; +} + +input { + padding: 10px; + font-size: 16px; + margin-top: 10px; + width: 100%; + box-sizing: border-box; +} + +button { + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + background-color: #00f; + color: #fff; + border: none; + border-radius: 5px; + margin-top: 10px; + transition: background-color 0.3s, box-shadow 0.3s; +} + +button:hover { + background-color: #003366; + box-shadow: 0 0 20px rgba(0, 255, 255, 0.8); +} + +p { + font-size: 18px; + margin-top: 20px; + color: #fff; +} + +.title { + padding: 20px; + margin: 0; + font-size: 36px; + font-weight: 900; + color: yellow; + transition: color 0.3s, transform 0.3s; +} + +.title:hover { + color: red; + transform: scale(1.1); +} + +.calculator-title { + color: #4caf50; + font-size: 24px; + font-weight: bold; + margin-bottom: 15px; +} \ No newline at end of file diff --git a/index.html b/index.html index 57e30865b..9f77d5415 100644 --- a/index.html +++ b/index.html @@ -1779,6 +1779,20 @@

Compute stress and strain using force, area, and length inputs.

+
+
+

Neon Number Calculator

+

Checks the number is neon or not and finds neon numbers in a range.

+ +
+