-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst(boot).html
More file actions
95 lines (87 loc) · 2.53 KB
/
first(boot).html
File metadata and controls
95 lines (87 loc) · 2.53 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
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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="bootstrap/bootstrap-5.0.0/css/bootstrap.min.css" rel="stylesheet" >
<title>Cyclicity of a Number</title>
<style>
.custom{
text-align: center;
background: silver;
margin: 3px;
min-height: 300px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="custom">
<form onsubmit="return false;">
<label style="font-size: 30px;">Enter a Number</label><br/><br/>
<input type="text" id="numb" name="numb"><br/><br/>
<button type="submit" onclick="cyclicity()" class="btn btn-primary">Submit</button>
</form>
<br/>
<div id="result" style="font-size: 30px;"></div><br/>
<button class="btn btn-secondary" onclick="expl()">Explanation</button><br/><br/>
<div id="exp"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var a1=[]
function cyclicity(){
var a=document.getElementById("numb").value;
if(isNaN(a)||a==""){
alert("enter a number");
}
else{
var arr=[];
var c=1;
var count=1;
while(c<=5){
var b=Math.pow(a,c);
a1.push(b);
arr.push(b);
c=c+1;
}
for(let i=1;i<arr.length;i++){
let last=arr[i]%10;
let l1=arr[0]%10;
if(l1==last){
break;
}
else{
count++;
}
}
document.getElementById("result").innerHTML="Cyclicity of "+a+" is: "+count;
}
}
function expl(){
if(a1.length==0){
document.getElementById("exp").innerHTML="Submit a number to know the eplanation";
}
/*else if(a1.length>5){
document.getElementById("exp").innerHTML="";
for(let i=5;i<a1.length;i++){
document.getElementById("exp").innerHTML+=a1[i]+"<br/>";
}
}*/
else{
document.getElementById("exp").innerHTML="";
for(let i=0;i<a1.length;i++){
document.getElementById("exp").innerHTML+=a1[i]+"<br/>";
}
}
a1=[];
}
</script>
</body>
</html>