-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutliplication_HARD.html
117 lines (82 loc) · 2.8 KB
/
mutliplication_HARD.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>factors</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="styles.css" rel="stylesheet">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
</head>
<body>
<a id="questionFE"></a>
<a>is</a>
<button class="Block" type="submit" onClick="onRefreshButtonClick(); document.getElementById('factor1').value = ''; document.getElementById('factor2').value = ''">NEW VALUES</button>
<br>
<input id="factor1" inputmode="numeric" class="inputfield" type="inputbox">
<input id="factor2" inputmode="numeric" class="inputfield" type="inputbox">
<button type="submit" onClick="checksolution()">checksolution</button>
<p id="resultprompt"></p>
<script>
const numbers = [123, 164, 205, 246, 287, 328, 369, 129, 172, 215, 258, 301, 344, 387, 141, 188, 235, 282, 329, 376, 423, 159, 212, 265, 318, 371, 424, 477, 177, 236, 295, 354, 413, 472, 531, 183, 244, 305, 366, 427, 488, 549, 201, 268, 335, 402, 469, 536, 603, 213, 284, 355, 426, 497, 568, 639, 219, 292, 365, 438, 511, 584, 657, 237, 316, 395, 474, 553, 632, 711, 249, 332, 415, 498, 581, 664, 747, 267, 356, 445, 534, 623, 712, 801, 291, 388, 485, 582, 679, 776, 873]
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,91);
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>