-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (107 loc) · 3.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prime Numbers</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0; /* Remove default margin */
padding: 2px; /* Add padding for content */
}
.container {
max-width: 350px;
margin: 0 auto; /* Center container */
text-align: center;
background: rgba(255, 255, 255, 0.8); /* Slightly transparent background for better readability */
padding: 20px;
border-radius: 10px; /* Rounded corners */
}
.text {
padding: 10px;
margin: 0 auto;
font-size: 25px;
font-weight: bold;
}
input {
padding: 15px;
font-size: 16px;
margin: 10px 0;
border-radius: 10px;
border: 1px solid rgb(5, 47, 235);
width: 100%; /* Full width */
box-sizing: border-box; /* Include padding and border in width */
}
button {
padding: 15px;
font-size: 16px;
margin: 10px 0;
border-radius: 10px;
color: white;
justify-content: center;
height: 3em;
width: 100%; /* Full width */
font-weight: 450;
background: linear-gradient(90deg, #1e39a5, #c50e07);
background-size: 300% 300%;
border: none; /* Remove border */
cursor:pointer; /* Change cursor on hover */
}
button:hover {
background-position:right; /* Change background on hover */
}
.id {
font-size: 25px;
font-weight: bold;
margin: 5px;
text-align: center;
width: 90%;
background: linear-gradient(135deg, #6adbbd, #1d48d6);
border-radius: 10px;
padding: 12px;
color: white; /* Text color */
}
.footer{
font-size: 12px;
margin-top: 5px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>Find Prime Numbers</h1>
<label class="text" for="primeLimit">Enter a Limit :</label>
<input type="number" id="primeLimit" placeholder="Enter a Number" />
<button onclick="findPrimes()">Show Prime</button>
<h2>Prime numbers:</h2>
<div class="id">
<footer class="footer">Re-Designed By Ranjithkumar.R ( <a href="https://github.com/beggarsmind">Beggar's Mind</a> )</footer>Output :
<p id="result">
</div>
</p>
</div>
<script>
function isPrime(num) {
if (num < 2) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
}
return true;
}
function findPrimes() {
let n = document.getElementById("primeLimit").value;
let result = "";
let lineNumber = 1;
for (let i = 2; i <= n; i++) {
if (isPrime(i)) {
result += lineNumber + ". " + i + "\n";
lineNumber++;
}
}
document.getElementById("result").innerText = result;
}
</script>
</body>
</html>