File size: 6,082 Bytes
8bf98dd
 
 
 
 
2ddb3ee
b8af0ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bf98dd
 
 
b8af0ba
8bf98dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8af0ba
8bf98dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8af0ba
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Prime Number Finder by SOMNATH</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #1a1a1a;
            color: #fff;
            min-height: 100vh;
            padding: 2rem;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        .title {
            font-size: 2rem;
            font-weight: bold;
            text-align: center;
            margin-bottom: 2rem;
            color: #6a5acd;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }
        .controls {
            background: #2a2a2a;
            padding: 1.5rem;
            border-radius: 10px;
            margin-bottom: 2rem;
        }
        .range-container {
            margin-bottom: 1rem;
        }
        .range-slider {
            width: 100%;
            height: 10px;
            -webkit-appearance: none;
            background: #3a3a3a;
            border-radius: 5px;
            outline: none;
        }
        .range-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 20px;
            height: 20px;
            background: #6a5acd;
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.3s;
        }
        .range-slider::-webkit-slider-thumb:hover {
            background: #8a7aed;
        }
        .btn {
            padding: 0.8rem 1.5rem;
            background: #6a5acd;
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 1rem;
            cursor: pointer;
            transition: background 0.3s;
        }
        .btn:hover {
            background: #8a7aed;
        }
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
            gap: 5px;
            margin-top: 2rem;
        }
        .number {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #2a2a2a;
            border-radius: 5px;
            font-size: 0.9rem;
            transition: all 0.3s;
        }
        .prime {
            animation: highlight 0.5s ease-out;
        }
        @keyframes highlight {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.1);
            }
            100% {
                transform: scale(1);
            }
        }
        .stats {
            margin-top: 2rem;
            padding: 1rem;
            background: #2a2a2a;
            border-radius: 10px;
        }
        .progress-bar {
            width: 100%;
            height: 10px;
            background: #3a3a3a;
            border-radius: 5px;
            overflow: hidden;
            margin-top: 1rem;
        }
        .progress {
            width: 0%;
            height: 100%;
            background: linear-gradient(90deg, #6a5acd, #8a7aed);
            transition: width 0.3s;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="title">Prime Number Finder by MOUSE(VIDraft-mouse1.hf.space)</h1>
        <div class="controls">
            <div class="range-container">
                <input type="range" min="1" max="999999" value="100" class="range-slider" id="range">
                <div>Range: <span id="rangeValue">100</span></div>
            </div>
            <button class="btn" id="findPrimes">Find Primes</button>
        </div>

        <div class="progress-bar">
            <div class="progress" id="progress"></div>
        </div>

        <div class="stats" id="stats">
            Primes found: 0
        </div>

        <div class="grid" id="grid"></div>
    </div>

    <script>
        const range = document.getElementById('range');
        const rangeValue = document.getElementById('rangeValue');
        const findPrimesBtn = document.getElementById('findPrimes');
        const grid = document.getElementById('grid');
        const progress = document.getElementById('progress');
        const stats = document.getElementById('stats');
        range.addEventListener('input', () => {
            rangeValue.textContent = range.value;
        });
        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 getRandomColor() {
            const hue = Math.random() * 360;
            return `hsl(${hue}, 70%, 60%)`;
        }
        async function findPrimes() {
            const maxNum = parseInt(range.value);
            grid.innerHTML = '';
            let primeCount = 0;
            for (let i = 1; i <= maxNum; i++) {
                const div = document.createElement('div');
                div.className = 'number';
                div.textContent = i;
                
                if (isPrime(i)) {
                    primeCount++;
                    div.style.backgroundColor = getRandomColor();
                    div.classList.add('prime');
                }
                grid.appendChild(div);
                // Update progress
                const progressValue = (i / maxNum) * 100;
                progress.style.width = `${progressValue}%`;
                // Update stats
                stats.textContent = `Primes found: ${primeCount}`;
                // Add small delay for visual effect and prevent browser freeze
                if (i % 100 === 0) {
                    await new Promise(resolve => setTimeout(resolve, 0));
                }
            }
        }
        findPrimesBtn.addEventListener('click', findPrimes);
    </script>
</body>
</html>