From 68dd3f425383d08de1bd3e5be0eb6a82d6c30cb9 Mon Sep 17 00:00:00 2001 From: kamalesh Date: Thu, 6 Jun 2024 12:50:18 +0530 Subject: [PATCH] Added Euclidean-Algorithm-Calculator --- .../Euclidean-Algorithm-Calculator/README.md | 19 +++ .../Euclidean-Algorithm-Calculator/index.html | 40 ++++++ .../Euclidean-Algorithm-Calculator/script.js | 45 +++++++ .../Euclidean-Algorithm-Calculator/style.css | 125 ++++++++++++++++++ index.html | 14 ++ 5 files changed, 243 insertions(+) create mode 100644 Calculators/Euclidean-Algorithm-Calculator/README.md create mode 100644 Calculators/Euclidean-Algorithm-Calculator/index.html create mode 100644 Calculators/Euclidean-Algorithm-Calculator/script.js create mode 100644 Calculators/Euclidean-Algorithm-Calculator/style.css diff --git a/Calculators/Euclidean-Algorithm-Calculator/README.md b/Calculators/Euclidean-Algorithm-Calculator/README.md new file mode 100644 index 000000000..4388d5122 --- /dev/null +++ b/Calculators/Euclidean-Algorithm-Calculator/README.md @@ -0,0 +1,19 @@ +# Euclidean Algorithm Calculator + +### Functionality :- +This calculator is a simple tool that to compute the Greatest Common Divisor (GCD) and the Least Common Multiple (LCM) of two integers entered by the user. + + +### Built Using :- + +- HTML +- CSS +- JavaScript + + +### Screenshot :- +Sample Output 1 :- +![image](https://github.com/Rakesh9100/CalcDiverse/assets/163159351/ce50851a-29df-48b8-8021-dd818fb4b39c) + +Sample Output 2 :- +![image](https://github.com/Rakesh9100/CalcDiverse/assets/163159351/baeef276-de95-4e75-b867-dec63d6b0ea5) \ No newline at end of file diff --git a/Calculators/Euclidean-Algorithm-Calculator/index.html b/Calculators/Euclidean-Algorithm-Calculator/index.html new file mode 100644 index 000000000..9a26682ba --- /dev/null +++ b/Calculators/Euclidean-Algorithm-Calculator/index.html @@ -0,0 +1,40 @@ + + + + + + + Euclidean Algorithm Calculator + + + +
+

Euclidean Algorithm

+

+ The Euclidean algorithm efficiently computes the greatest common divisor (GCD) of two integers, + which is the largest number that divides both without a remainder. Additionally, you can find the + least common multiple (LCM) using the GCD with the formula: LCM(A, B) = (A * B) / GCD(A, B). +

+
+
+
+ + +
+
+ + +
+
+ +
+

+ GCD(, ) = +

+

+ LCM(, ) = +

+
+ + + diff --git a/Calculators/Euclidean-Algorithm-Calculator/script.js b/Calculators/Euclidean-Algorithm-Calculator/script.js new file mode 100644 index 000000000..993744dd7 --- /dev/null +++ b/Calculators/Euclidean-Algorithm-Calculator/script.js @@ -0,0 +1,45 @@ +const form=document.querySelector(".form-container") +const submitBtn=document.querySelector(".submit") +form.addEventListener("submit",calculate); + +function calculate(e){ + e.preventDefault(); + let a=document.querySelector(".num1").value; + let b=document.querySelector(".num2").value; + + let res=gcd(a,b); + let res2=lcm(a,b); + + const gcdFinal=document.querySelector(".gcd-final"); + const lcmFinal=document.querySelector(".lcm-final"); + + const gcdVal=document.querySelector(".gcd"); + const lcmVal=document.querySelector(".lcm"); + const num1=document.querySelector(".n1"); + const num2=document.querySelector(".n2"); + const num3=document.querySelector(".n3"); + const num4=document.querySelector(".n4"); + + gcdVal.innerText=res; + lcmVal.innerText=res2; + + num1.innerText=a; + num2.innerText=b; + num3.innerText=a; + num4.innerText=b; + + gcdFinal.classList.add("show"); + lcmFinal.classList.add("show"); +} +function gcd(a,b){ + var r; + while((a%b)>0){ + r=a%b + a=b + b=r + } + return b +} +function lcm(a,b){ + return a*b/gcd(a,b); +} \ No newline at end of file diff --git a/Calculators/Euclidean-Algorithm-Calculator/style.css b/Calculators/Euclidean-Algorithm-Calculator/style.css new file mode 100644 index 000000000..319bea14f --- /dev/null +++ b/Calculators/Euclidean-Algorithm-Calculator/style.css @@ -0,0 +1,125 @@ +@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&display=swap'); + +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: 'Open Sans', sans-serif; + user-select: none; +} + +body { + background: linear-gradient(135deg, #2a2a2a, #121212); + color: #e0e0e0; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + overflow: hidden; +} + +.container { + background: rgba(30, 30, 30, 0.9); + border-radius: 15px; + box-shadow: 0 0 30px rgba(0, 0, 0, 0.5); + text-align: center; + max-width: 600px; + padding: 40px 20px; + backdrop-filter: blur(10px); +} + +.container h1 { + font-size: 32px; + color: #ffffff; + font-weight: 700; + text-transform: uppercase; + margin-bottom: 20px; + letter-spacing: 2px; +} + +.container p { + font-size: 16px; + color: #b0b0b0; + margin-bottom: 30px; + line-height: 1.6; + animation: fadeIn 2s ease-in-out; +} + +.inp-container { + display: flex; + flex-direction: column; + gap: 20px; +} + +.values { + display: flex; + flex-direction: column; + align-items: flex-start; +} + +.inp-container label { + font-size: 14px; + color: #cccccc; + margin-bottom: 5px; +} + +.inp-container input { + width: 100%; + padding: 10px; + border: 1px solid #444; + border-radius: 8px; + background: #2c2c2c; + color: #e0e0e0; + font-size: 16px; + transition: all 0.3s ease; +} + +.inp-container input:focus { + border-color: #3498db; + box-shadow: 0 0 10px rgba(52, 152, 219, 0.5); +} + +.submit { + margin-top: 20px; + padding: 10px 20px; + font-size: 16px; + font-weight: 500; + color: #ffffff; + background: linear-gradient(135deg, #3498db, #2ecc71); + border: none; + border-radius: 8px; + cursor: pointer; + transition: background 0.3s ease; +} + +.submit:hover { + background: linear-gradient(135deg, #2980b9, #27ae60); +} + +.gcd-final, .lcm-final { + margin-top: 20px; + font-size: 20px; + color: #ffffff; + display: none; + animation: fadeIn 1s ease-in-out; +} + +.gcd-final.show, .lcm-final.show { + display: block; +} + +.gcd-final .gcd, .lcm-final .lcm { + color: #e74c3c; + font-weight: 700; +} + +@keyframes fadeIn { + 0% { + opacity: 0; + transform: translateY(-20px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} \ No newline at end of file diff --git a/index.html b/index.html index 2f191bd85..84bd1ff03 100644 --- a/index.html +++ b/index.html @@ -1114,6 +1114,20 @@

Calculates the Equivalent Resistance of the Series and Parallel Configuratio +
+
+

Euclidean-Algorithm-Calculator

+

Calculates the Greatest Common Divisor (GCD) and the Least Common Multiple (LCM).

+ +
+

Expenditure And Savings Calculator