From 0a1164b6583779044d0427a64faceb462c04d4dd Mon Sep 17 00:00:00 2001 From: AftabMankapure Date: Wed, 21 Feb 2024 23:42:07 +0530 Subject: [PATCH 1/8] added cuban prime number calculator --- Calculators/Cuban-Prime-Calculator/READMe.md | 15 ++++ Calculators/Cuban-Prime-Calculator/index.html | 38 +++++++++ Calculators/Cuban-Prime-Calculator/script.js | 61 ++++++++++++++ Calculators/Cuban-Prime-Calculator/style.css | 82 +++++++++++++++++++ index.html | 15 ++++ 5 files changed, 211 insertions(+) create mode 100644 Calculators/Cuban-Prime-Calculator/READMe.md create mode 100644 Calculators/Cuban-Prime-Calculator/index.html create mode 100644 Calculators/Cuban-Prime-Calculator/script.js create mode 100644 Calculators/Cuban-Prime-Calculator/style.css diff --git a/Calculators/Cuban-Prime-Calculator/READMe.md b/Calculators/Cuban-Prime-Calculator/READMe.md new file mode 100644 index 000000000..e50f6f523 --- /dev/null +++ b/Calculators/Cuban-Prime-Calculator/READMe.md @@ -0,0 +1,15 @@ +#

Cuban Prime Number Calculator

+ +## Description :- + +This calculator will help you convert your input data sizes in following sizes +Bits, Nibbles,Bytes,Kilobytes,Megabytes,Gigabytes,Terabytes,Petabytes,Exabytes,Zetabytes,Yottabytes + +## Tech Stack :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- +![image](https://github.com/Akshansh8/CalcDiverse/assets/91936333/a87fab3e-2619-41dc-a62f-2193fe62c082) diff --git a/Calculators/Cuban-Prime-Calculator/index.html b/Calculators/Cuban-Prime-Calculator/index.html new file mode 100644 index 000000000..df4c78165 --- /dev/null +++ b/Calculators/Cuban-Prime-Calculator/index.html @@ -0,0 +1,38 @@ + + + + + + + + Cuban Prime Calculator + + + + +

Cuban Prime Calculator

+ +
+
+

Check Single Cuban Prime

+ + + +

+
+ +
+

Check Cuban Primes in Range

+ + + + + +

+
+
+ + + + + diff --git a/Calculators/Cuban-Prime-Calculator/script.js b/Calculators/Cuban-Prime-Calculator/script.js new file mode 100644 index 000000000..a563196f3 --- /dev/null +++ b/Calculators/Cuban-Prime-Calculator/script.js @@ -0,0 +1,61 @@ +function isPrime(num) { + if (num < 2) { + return false; + } + for (let i = 2; i <= num / 2; i++) { + if (num % i === 0) { + return false; + } + } + return true; +} + +function cubeOfNum(num) { + return num * num * num; +} + +function isCubanPrime(num) { + let res = cubeOfNum(num) - cubeOfNum(num - 1); + return isPrime(res) && isPrime(num); +} + +function checkCubanPrime() { + let number = document.getElementById('number').value; + + if (!validateInput(number)) { + alert('Please enter a valid positive integer.'); + return; + } + + let result = isCubanPrime(parseInt(number)); + + document.getElementById('resultSingle').innerText = `${number} is ${result ? '' : 'not '}a Cuban Prime number.`; +} + +function checkCubanPrimesInRange() { + 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 cubanPrimes = []; + + for (let i = fromRange; i <= toRange; i++) { + if (isCubanPrime(i)) { + cubanPrimes.push(i); + } + } + + if (cubanPrimes.length > 0) { + document.getElementById('rangeResult').innerText = `Cuban Prime numbers in the range ${fromRange} to ${toRange}: ${cubanPrimes.join(', ')}`; + } else { + document.getElementById('rangeResult').innerText = `There are no Cuban Prime numbers in the range ${fromRange} to ${toRange}.`; + } +} + +function validateInput(number) { + return /^(0|[1-9]\d*)$/.test(number); +} diff --git a/Calculators/Cuban-Prime-Calculator/style.css b/Calculators/Cuban-Prime-Calculator/style.css new file mode 100644 index 000000000..5e9078f07 --- /dev/null +++ b/Calculators/Cuban-Prime-Calculator/style.css @@ -0,0 +1,82 @@ +body { + font-family: 'Roboto', sans-serif; + text-align: center; + margin: 0; + padding: 0; + background: linear-gradient(135deg, #2980B9, #6DD5FA); + color: #fff; +} + +.calculator { + display: flex; + justify-content: space-around; + align-items: flex-start; + margin: 50px auto; + max-width: 900px; +} + +.section { + width: 45%; + padding: 20px; + box-sizing: border-box; + background: linear-gradient(45deg, #1E2A39, #394A5E); + border: 1px solid #00f; + border-radius: 15px; + box-shadow: 0 0 20px rgba(255, 255, 255, 0.8); + margin-bottom: 20px; +} + +input { + padding: 10px; + font-size: 16px; + margin-top: 10px; + width: 100%; + box-sizing: border-box; + background-color: #fff; + border: none; + border-radius: 5px; +} + +button { + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + background-color: #3498DB; + color: #fff; + border: none; + border-radius: 5px; + margin-top: 10px; + transition: background-color 0.3s, box-shadow 0.3s; +} + +button:hover { + background-color: #2980B9; + box-shadow: 0 0 20px rgba(255, 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: #FFC300; + transition: color 0.3s, transform 0.3s; +} + +.title:hover { + color: #E74C3C; + transform: scale(1.1); +} + +.calculator-title { + color: #2ECC71; + font-size: 24px; + font-weight: bold; + margin-bottom: 15px; +} diff --git a/index.html b/index.html index 3059b24b8..69e9d1b69 100644 --- a/index.html +++ b/index.html @@ -1836,6 +1836,21 @@

Checks if a number is circular prime and finds circular prime numbers in a r + +
+
+

Cuban Prime Number Calculator

+

Checks if a number is cuban prime or not and finds cuban prime numbers in a range.

+ +
+
From 322da2d37aab3b2d705d610a4c51a1d0f1f9b390 Mon Sep 17 00:00:00 2001 From: AftabMankapure Date: Wed, 21 Feb 2024 23:45:31 +0530 Subject: [PATCH 2/8] readme update --- Calculators/Cuban-Prime-Calculator/READMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calculators/Cuban-Prime-Calculator/READMe.md b/Calculators/Cuban-Prime-Calculator/READMe.md index e50f6f523..cafcbf9fb 100644 --- a/Calculators/Cuban-Prime-Calculator/READMe.md +++ b/Calculators/Cuban-Prime-Calculator/READMe.md @@ -12,4 +12,4 @@ Bits, Nibbles,Bytes,Kilobytes,Megabytes,Gigabytes,Terabytes,Petabytes,Exabytes,Z - JavaScript ## Screenshots :- -![image](https://github.com/Akshansh8/CalcDiverse/assets/91936333/a87fab3e-2619-41dc-a62f-2193fe62c082) +![Cuban](https://github.com/Rakesh9100/CalcDiverse/assets/125949765/61d9e288-e8bd-4be2-8a09-babb2bac3f1b) From 0336a60bac2b4417547f6c10a68af52be2a9fc53 Mon Sep 17 00:00:00 2001 From: AftabMankapure Date: Thu, 22 Feb 2024 00:59:24 +0530 Subject: [PATCH 3/8] result set update --- .vscode/settings.json | 3 ++ Calculators/Cuban-Prime-Calculator/READMe.md | 17 +++++++--- Calculators/Cuban-Prime-Calculator/index.html | 19 +++++++++++ Calculators/Cuban-Prime-Calculator/script.js | 13 ++++++-- Calculators/Cuban-Prime-Calculator/style.css | 33 +++++++++++++++++++ 5 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..6f3a2913e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Calculators/Cuban-Prime-Calculator/READMe.md b/Calculators/Cuban-Prime-Calculator/READMe.md index cafcbf9fb..8c5f168b8 100644 --- a/Calculators/Cuban-Prime-Calculator/READMe.md +++ b/Calculators/Cuban-Prime-Calculator/READMe.md @@ -1,15 +1,24 @@ -#

Cuban Prime Number Calculator

+#

Cuban Prime Checker

## Description :- -This calculator will help you convert your input data sizes in following sizes -Bits, Nibbles,Bytes,Kilobytes,Megabytes,Gigabytes,Terabytes,Petabytes,Exabytes,Zetabytes,Yottabytes +Cuban Prime Checker is a web application that allows users to identify and find Cuban prime numbers within a specified range. -## Tech Stack :- +* Checks if a number is a Cuban prime. +* Finds Cuban prime numbers within a specified range. + +## What is a Cuban Prime? + +A Cuban prime is a prime number that is a solution to the Diophantine equation x^3 + y^3 = z^3 + 1, where x, y, and z are positive integers. In other words, it's a special type of prime number related to the sum of cubes. + +For example, 2, 19, 37 are Cuban primes as they satisfy the mentioned Diophantine equation. + +## Tech Stacks :- - HTML - CSS - JavaScript + ## Screenshots :- ![Cuban](https://github.com/Rakesh9100/CalcDiverse/assets/125949765/61d9e288-e8bd-4be2-8a09-babb2bac3f1b) diff --git a/Calculators/Cuban-Prime-Calculator/index.html b/Calculators/Cuban-Prime-Calculator/index.html index df4c78165..7262663f5 100644 --- a/Calculators/Cuban-Prime-Calculator/index.html +++ b/Calculators/Cuban-Prime-Calculator/index.html @@ -11,7 +11,24 @@

Cuban Prime Calculator

+
+

What is a Cuban Prime?

+

+ A Cuban prime is a prime number that is a solution to the Diophantine equation x^3 + y^3 = z^3 + 1, where x, y, and z are positive integers. + It's a special type of prime number related to the sum of cubes. +

+

Formula:

+

+ The Diophantine equation for Cuban primes is x^3 + y^3 = z^3 + 1. +

+ +

Solution Process:

+

+ When checking a number for Cuban primality, the application verifies if the given number satisfies the Diophantine equation. + The application then checks if both the calculated value and the given number are prime. If the conditions are met, the number is identified as a Cuban Prime. +

+

Check Single Cuban Prime

@@ -32,6 +49,8 @@

Cuban Prime Calculator

+ + diff --git a/Calculators/Cuban-Prime-Calculator/script.js b/Calculators/Cuban-Prime-Calculator/script.js index a563196f3..30629089b 100644 --- a/Calculators/Cuban-Prime-Calculator/script.js +++ b/Calculators/Cuban-Prime-Calculator/script.js @@ -19,6 +19,11 @@ function isCubanPrime(num) { return isPrime(res) && isPrime(num); } +function getCubanSolution(num) { + let res = cubeOfNum(num) - cubeOfNum(num - 1); + return `
The cube of ${num} is ${cubeOfNum(num)}.
The cube of ${num - 1} is ${cubeOfNum(num - 1)}.
The difference is ${res}.
This number is Cuban Prime because both ${num} and ${res} are prime.`; +} + function checkCubanPrime() { let number = document.getElementById('number').value; @@ -28,8 +33,9 @@ function checkCubanPrime() { } let result = isCubanPrime(parseInt(number)); + let message = result ? `${number} is a Cuban Prime number. ${getCubanSolution(parseInt(number))}` : `${number} is not a Cuban Prime number.`; - document.getElementById('resultSingle').innerText = `${number} is ${result ? '' : 'not '}a Cuban Prime number.`; + document.getElementById('resultSingle').innerHTML = `${message}`; } function checkCubanPrimesInRange() { @@ -50,9 +56,10 @@ function checkCubanPrimesInRange() { } if (cubanPrimes.length > 0) { - document.getElementById('rangeResult').innerText = `Cuban Prime numbers in the range ${fromRange} to ${toRange}: ${cubanPrimes.join(', ')}`; + let solutions = cubanPrimes.map(num => getCubanSolution(num)); + document.getElementById('rangeResult').innerHTML = `Cuban Prime numbers in the range ${fromRange} to ${toRange}: ${cubanPrimes.join(', ')}. Solutions:
${solutions.join('
')}
`; } else { - document.getElementById('rangeResult').innerText = `There are no Cuban Prime numbers in the range ${fromRange} to ${toRange}.`; + document.getElementById('rangeResult').innerHTML = `There are no Cuban Prime numbers in the range ${fromRange} to ${toRange}.`; } } diff --git a/Calculators/Cuban-Prime-Calculator/style.css b/Calculators/Cuban-Prime-Calculator/style.css index 5e9078f07..d048fd661 100644 --- a/Calculators/Cuban-Prime-Calculator/style.css +++ b/Calculators/Cuban-Prime-Calculator/style.css @@ -80,3 +80,36 @@ p { font-weight: bold; margin-bottom: 15px; } + +.information { + text-align: justify; + margin-top: 30px; + color: #fff; + max-width: 800px; + margin-left: auto; + margin-right: auto; + border: 1px solid #00f; + border-radius: 15px; + padding: 20px; + box-shadow: 0 0 20px rgba(255, 255, 255, 0.8); +} + + +.information h2 { + color: #FFC300; + font-size: 24px; + margin-bottom: 10px; +} + +.information p { + font-size: 16px; + line-height: 1.6; + margin-bottom: 20px; +} +.cuban-prime { + color: #2ECC71; /* Green color for Cuban Prime */ +} + +.not-cuban-prime { + color: #E74C3C; /* Red color for not Cuban Prime */ +} From 5e9676c09826cd7ebd85d9f4dfe8dd5f79e92129 Mon Sep 17 00:00:00 2001 From: Aftab Mankapure <125949765+AftabMankapure@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:57:54 +0530 Subject: [PATCH 4/8] Update style.css --- Calculators/Cuban-Prime-Calculator/style.css | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Calculators/Cuban-Prime-Calculator/style.css b/Calculators/Cuban-Prime-Calculator/style.css index d048fd661..93be44348 100644 --- a/Calculators/Cuban-Prime-Calculator/style.css +++ b/Calculators/Cuban-Prime-Calculator/style.css @@ -59,6 +59,9 @@ p { margin-top: 20px; color: #fff; } +.cuban-prime-result { + color: #2ECC71; +} .title { padding: 20px; @@ -107,9 +110,11 @@ p { margin-bottom: 20px; } .cuban-prime { - color: #2ECC71; /* Green color for Cuban Prime */ -} + color: #2ECC71; } .not-cuban-prime { - color: #E74C3C; /* Red color for not Cuban Prime */ + color: #E74C3C; +} +.rangeResult{ + color: #2ECC71; } From 1989f016b94db549e85d5168840a35cbe7bd092d Mon Sep 17 00:00:00 2001 From: Aftab Mankapure <125949765+AftabMankapure@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:58:27 +0530 Subject: [PATCH 5/8] Update script.js --- Calculators/Cuban-Prime-Calculator/script.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Calculators/Cuban-Prime-Calculator/script.js b/Calculators/Cuban-Prime-Calculator/script.js index 30629089b..6b6224c1e 100644 --- a/Calculators/Cuban-Prime-Calculator/script.js +++ b/Calculators/Cuban-Prime-Calculator/script.js @@ -56,8 +56,7 @@ function checkCubanPrimesInRange() { } if (cubanPrimes.length > 0) { - let solutions = cubanPrimes.map(num => getCubanSolution(num)); - document.getElementById('rangeResult').innerHTML = `Cuban Prime numbers in the range ${fromRange} to ${toRange}: ${cubanPrimes.join(', ')}. Solutions:
${solutions.join('
')}
`; + document.getElementById('rangeResult').innerHTML = `Cuban Prime numbers in the range ${fromRange} to ${toRange}: ${cubanPrimes.join(', ')}`; } else { document.getElementById('rangeResult').innerHTML = `There are no Cuban Prime numbers in the range ${fromRange} to ${toRange}.`; } From 41c77c8209c80a16458015269bfd27a11b7aebe3 Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sun, 25 Feb 2024 00:34:37 +0530 Subject: [PATCH 6/8] Delete .vscode directory --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6f3a2913e..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "liveServer.settings.port": 5501 -} \ No newline at end of file From 86f43b6f01c922bd00e8ad17b1ac9507edaa012e Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sun, 25 Feb 2024 00:37:34 +0530 Subject: [PATCH 7/8] Update index.html --- index.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 74efd7595..8307ae23a 100644 --- a/index.html +++ b/index.html @@ -1883,17 +1883,16 @@

Calculates the time in which you can payoff your Credits.

-
-

Cuban Prime Number Calculator

-

Checks if a number is cuban prime or not and finds cuban prime numbers in a range.

+

Cuban Prime Calculator

+

Checks if a number is cuban prime or not and finds cuban prime numbers in a range.

From ba12bdb088329f62848ba39cd1853b8713ef650e Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Sun, 25 Feb 2024 00:40:36 +0530 Subject: [PATCH 8/8] Rename READMe.md to README.md --- Calculators/Cuban-Prime-Calculator/{READMe.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Calculators/Cuban-Prime-Calculator/{READMe.md => README.md} (100%) diff --git a/Calculators/Cuban-Prime-Calculator/READMe.md b/Calculators/Cuban-Prime-Calculator/README.md similarity index 100% rename from Calculators/Cuban-Prime-Calculator/READMe.md rename to Calculators/Cuban-Prime-Calculator/README.md