<html>
<head>
<link rel="stylesheet" href="Test.css" type="text/css" />
<script type="text/javascript" src="Test.js"></script>
</head>
<style>
.container {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
right: 0;
left: 0;
bottom: 0;
top: 0;
background-image: linear-gradient(
to right,
rgba(255, 0, 0, 0),
rgba(255, 0, 0, 1)
);
}
#val {
width: 25%;
height: 3%;
font-size: 15px;
box-shadow: 0 15px 15px 0 rgba(0, 0, 0, 0.5);
}
#val:hover {
background-color: aqua;
}
#val:focus {
background-color: yellow;
color: green;
}
#asal {
position: absolute;
left: 63.5%;
height: 4%;
box-shadow: 0 15px 15px 0 rgba(0, 0, 0, 0.5);
padding-left: 5px;
border-radius: 15px;
}
#AsalBas {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
right: 0;
left: 0;
top: 30%;
font-family: sans-serif;
font-size: 30px;
}
</style>
<body>
<h2 id="AsalBas">Asal Sayı Kontrolü</h2>
<div class="container">
<input id="val" type="number" value="0" />
<button type="button" id="asal" onclick="asal(this.value)">
Click
</button>
</div>
<script type="text/javascript">
function asal() {
var sayac = 0;
var deger = document.getElementById("val").value;
var i, j;
for (i = 2; i < deger; i++) {
if (deger % i == 0) {
sayac++;
}
}
if (deger != 1 && deger != 0) {
if (sayac == 0 || deger == 2) {
alert("2Asaldır.");
} else {
alert("2Asal değildir.");
}
} else {
alert("Girilen parametre degeri 1 veya 0 olmamalıdır.");
}
}
</script>
</body>
</html>