-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutliplication.html
126 lines (92 loc) · 3.47 KB
/
mutliplication.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
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<title>factors</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Your name">
<meta name="description" content="Brief description">
<meta property="og:title" content="Your Page Title">
<meta property="og:description" content="Brief description">
<meta property="og:image" content="/some-image.png">
<meta property="og:url" content="/this-page.html">
<meta property="og:site_name" content="Your Site Name">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image:alt" content="image description">
<link href="./styles.css" rel="stylesheet">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
</head>
<body>
<a id="questionFE" ></a>
<br>
<br>
<input id="factor1" inputmode="numeric" class="inputfield" type="inputbox">
<input id="factor2" inputmode="numeric" class="inputfield" type="inputbox">
<button class="Block" type="submit" onClick="onRefreshButtonClick(); document.getElementById('factor1').value = ''; document.getElementById('factor2').value = ''">NEW VALUES</button>
<br>
<button class="Block" type="submit" onClick="checksolution()">checksolution</button>
<p id="resultprompt"></p>
<script>
const numbers = [36, 48, 60, 72, 84, 96, 108, 39, 52, 65, 78, 91, 104, 117, 42, 56, 70, 84, 98, 112, 126, 45, 60, 75, 90, 105, 120, 135, 48, 64, 80, 96, 112, 128, 144, 51, 68, 85, 102, 119, 136, 153, 54, 72, 90, 108, 126, 144, 162, 57, 76, 95, 114, 133, 152, 171, 63, 84, 105, 126, 147, 168, 189, 66, 88, 110, 132, 154, 176, 198, 69, 92, 115, 138, 161, 184, 207, 72, 96, 120, 144, 168, 192, 216, 75, 100, 125, 150, 175, 200, 225, 78, 104, 130, 156, 182, 208, 234, 81, 108, 135, 162, 189, 216, 243, 84, 112, 140, 168, 196, 224, 252, 87, 116, 145, 174, 203, 232, 261, 93, 124, 155, 186, 217, 248, 279, 111, 148, 185, 222, 259, 296, 333]
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
let questionforcheck= ""
function onRefreshButtonClick() {
let randnum = getRandomInt(1,133);
const question = numbers[randnum];
document.getElementById("questionFE").innerHTML = question;
questionforcheck = question;
}
function checksolution() {
const x = document.getElementById("factor1").value;
const y = document.getElementById("factor2").value;
res = x*y
res = String(res)
if (questionforcheck == res) {
text = "Correct!";
factor()
mathtables()
}
else {
text = "Incorrect";
}
document.getElementById("resultprompt").innerHTML = text;
}
function factor(){
x=questionforcheck
x=parseInt(x)
if(Number.isInteger(x)){
str='';
//Highest divisor can be less than half of the input number
x1=Math.ceil(x/2)
for(i=2;i<=x1;i++){
if(x%i==0){
str = str + i + ', '
}
}
document.getElementById('d1').innerHTML="Other factors are: " + str
}else{
}
}
function mathtables(){
intfortables=questionforcheck
intfortables=parseInt(intfortables)
if(Number.isInteger(intfortables)){
str='';
xy1=Math.ceil(intfortables/2)
for(i=2;i<=xy1;i++){
if(intfortables%i==0){
str = str + intfortables/i + ' X ' + i + ' = ' + intfortables + "<br>"
}
}
document.getElementById('tables').innerHTML=str
} else{}}
</script>
<p id="d1"></p>
<button class="Block" type="submit" onClick="mathtables()">never seen this before</button>
<p id="tables"></p>
</body>
</html>