This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
prime_factorization.html
93 lines (77 loc) · 3.76 KB
/
prime_factorization.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
<!DOCTYPE html>
<html data-require="math graphie">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Prime factorization</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="cx">0</var>
<var id="y">0</var>
</div>
<div class="problems">
<div id="prime">
<div class="vars">
<var id="NUMBER">getPrime()</var>
</div>
<p class="question">What is the prime factorization of <code><var>NUMBER</var></code>?</p>
<p class="solution" data-type="primeFactorization"><var>NUMBER</var></p>
<div class="hints">
<p>Let us draw a factor tree.</p>
<div class="graphie" id="factor-tree">
init({
range: [ [-1, 2], [-1, 1] ],
scale: [30, 30]
});
label( [cx, y], NUMBER );
</div>
<div class="graphie" data-update="factor-tree">
circle( [cx, y], 0.5 );
</div>
<p>Because <code><var>NUMBER</var></code> is prime, its prime factorization is simply <code><var>NUMBER</var></code>.</p>
</div>
</div>
<div id="composite" data-weight="3">
<div class="vars">
<var id="NUMBER">getComposite()</var>
<var id="SOLUTION">getPrimeFactorization( NUMBER )</var>
<var id="FACTORIZATION">SOLUTION.slice( 0, SOLUTION.length - 1 )</var>
<var id="curr">NUMBER</var>
</div>
<p class="question">What is the prime factorization of <code><var>NUMBER</var></code>?</p>
<p class="solution" data-type="primeFactorization"><var>SOLUTION.join("x")</var></p>
<div class="hints">
<div>
<p>Let us draw a factor tree.</p>
<div class="graphie" id="factor-tree">
init({
range: [ [-1, FACTORIZATION.length + 2], [ -2 * FACTORIZATION.length - 1, 1] ],
scale: [30, 30]
});
label( [cx + 1, y], curr );
</div>
</div>
<div class="graphie" data-update="factor-tree" data-each="FACTORIZATION as factor">
path( [ [cx + 1, y - 0.5], [cx, y - 1.5] ] );
path( [ [cx + 1, y - 0.5], [cx + 2, y - 1.5] ] );
y -= 2;
cx += 1;
curr = curr / factor;
label( [cx - 1, y], factor );
circle( [cx - 1, y], 0.5);
label( [cx + 1, y], curr );
</div>
<div class="graphie" data-update="factor-tree">
circle( [cx + 1, y], 0.5);
</div>
<p>The prime factorization of <code><var>NUMBER</var></code> is <code><var>SOLUTION.join(" × ")</var></code>.</p>
</div>
</div>
</div>
<div class="hints">
</div>
</div>
</body>
</html>