diff --git a/Calculators/Prime-Number-Finder/assets/background.jpg b/Calculators/Prime-Number-Finder/assets/background.jpg new file mode 100644 index 000000000..0a597cbe4 Binary files /dev/null and b/Calculators/Prime-Number-Finder/assets/background.jpg differ diff --git a/Calculators/Prime-Number-Finder/assets/star.jpeg b/Calculators/Prime-Number-Finder/assets/star.jpeg new file mode 100644 index 000000000..d512a2f2d Binary files /dev/null and b/Calculators/Prime-Number-Finder/assets/star.jpeg differ diff --git a/Calculators/Prime-Number-Finder/index.html b/Calculators/Prime-Number-Finder/index.html new file mode 100644 index 000000000..d2f9a027a --- /dev/null +++ b/Calculators/Prime-Number-Finder/index.html @@ -0,0 +1,24 @@ + + + + + + Prime Number Finder + + + +
+

Prime Number Finder

+
+

Enter a number to check if it's a prime number.

+ + +

+ +
+
+ + + + + diff --git a/Calculators/Prime-Number-Finder/script.js b/Calculators/Prime-Number-Finder/script.js new file mode 100644 index 000000000..1c25a446d --- /dev/null +++ b/Calculators/Prime-Number-Finder/script.js @@ -0,0 +1,27 @@ +function checkPrime() { + const number = parseInt(document.getElementById('numberInput').value); + const resultElement = document.getElementById('result'); + const starImage = document.getElementById('starImage'); + + if (number <= 1) { + resultElement.textContent = `${number} is not a prime number.`; + starImage.style.display = 'none'; + return; + } + + let isPrime = true; + for (let i = 2; i <= Math.sqrt(number); i++) { + if (number % i === 0) { + isPrime = false; + break; + } + } + + if (isPrime) { + resultElement.textContent = `${number} is a prime number!`; + starImage.style.display = 'inline'; + } else { + resultElement.textContent = `${number} is not a prime number.`; + starImage.style.display = 'none'; + } +} \ No newline at end of file diff --git a/Calculators/Prime-Number-Finder/styles.css b/Calculators/Prime-Number-Finder/styles.css new file mode 100644 index 000000000..16f73c89c --- /dev/null +++ b/Calculators/Prime-Number-Finder/styles.css @@ -0,0 +1,78 @@ +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background-image: url('assets/background.jpg'); + background-size: cover; + background-position: center; + background-repeat: no-repeat; + background-attachment: fixed; + background-color: #e0e0e0; +} + +.container { + background-color: black; + opacity: .8; + padding: 2rem; + border-radius: 12px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + text-align: center; + max-width: 400px; + width: 100%; +} + +h1 { + color: white; + font-size: 1.8rem; + margin-bottom: 1rem; +} + +.calculator { + margin-top: 1.5rem; + color: white; +} + +input { + padding: 0.75rem; + font-size: 1rem; + width: 100%; + max-width: 220px; + margin-bottom: 1rem; + border: 1px solid #ddd; + border-radius: 6px; + box-sizing: border-box; +} + +button { + padding: 0.75rem 1.25rem; + font-size: 1rem; + background-color: #3498db; + color: #ffffff; + border: none; + border-radius: 6px; + cursor: pointer; + transition: background-color 0.3s, transform 0.2s; +} + +button:hover { + background-color: #2980b9; + transform: translateY(-2px); +} + +#result { + margin-top: 1.5rem; + font-weight: bold; + color: #e74c3c; + font-size: 1.2rem; +} + +#starImage { + width: 60px; + height: 60px; + margin-top: 1.5rem; + border-radius: 50%; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} diff --git a/index.html b/index.html index 798b7d606..4c90944a4 100644 --- a/index.html +++ b/index.html @@ -3853,6 +3853,22 @@

Calculates the prime factors of the given number.

+
+
+
+

Prime Number Finder

+

Calculates whether given number is Prime or not

+ +
+
+

Probability Calculator