-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path042 asalSayiBul.html
More file actions
53 lines (42 loc) · 1.35 KB
/
042 asalSayiBul.html
File metadata and controls
53 lines (42 loc) · 1.35 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aralık Toplam</title>
<script>
function asalKontrol(sayi){
asal=true;
if (sayi==1 || sayi==0) return false;
if (sayi==2) return true;
for(i=2;i<sayi;i++){
if(sayi%i==0)
asal=false;
}
return asal;
}
function hesapla(){
let i, toplam=0, sayilar="";
sayi1=parseInt(document.getElementById("s1").value);
sayi2=parseInt(document.getElementById("s2").value);
for(i=sayi1;i<=sayi2;i++){
if (asalKontrol(i))
{
sayilar+=i+" ";
}
document.getElementById("sonuc").value=sayilar;
}
}
</script>
</head>
<body>
<label for="s1">Sayı 1:</label>
<input type="number" id="s1"> <br>
<label for="s2">Sayı 2:</label>
<input type="number" id="s2"> <br>
<textarea id="sonuc" cols="30" rows="5">
</textarea> <br>
<button onclick="hesapla()">Asal Sayıları Bul</button>
<!-- <div id="sonuc"></div>-->
</body>
</html>