-
Notifications
You must be signed in to change notification settings - Fork 7
/
ModularAddMulSub.html
202 lines (187 loc) · 8.87 KB
/
ModularAddMulSub.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Abel" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Monoton" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<!-- TITLE AND CUSTOM CSS -->
<title> Modular Arithmetic </title>
<link rel="stylesheet" href="css/ma.css">
</head>
<body>
<!-- ENTER HEADER HERE -->
<div class="header">
<h1 style="color: whitesmoke">Number theory</h1>
<p style="color: whitesmoke">Theory Of Numbers</p>
</div>
<div class="topnav">
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">←</a>
<a href="https://www.amazon.com/s/ref=nb_sb_noss_2/144-7551219-7280505?url=search-alias%3Daps&field-keywords=number+theory">Shop</a>
<a href='#'>Books</a>
<a href='Devs.html'>Developers</a>
<a href='#' id="feed">Feedback</a>
</div><a style="font-size:20px;cursor:pointer ;color:white ; padding-bottom: 8px" onclick="openNav()">☰</a>
<a href="index.html">Home</a>
<div class="dropdown">
<button class="dropbtn">
Primes
<!--<i class="fa fa-caret-down"></i>-->
</button>
<div class="dropdown-content">
<a href="Primality.html">Introduction</a>
<a href="PrimeFact.html">Prime Factors</a>
<a href="RSA.html">RSA Encryption</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">
Modular Arithmetic
<!--<i class="fa fa-caret-down"></i>-->
</button>
<div class="dropdown-content">
<a href="welcome.html">Introduction</a>
<a href="ModularAddMulSub.html">Modular Arithmetic</a>
<a href="congo.html">Modular Congruency</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">
Algorithms
<!--<i class="fa fa-caret-down"></i>-->
</button>
<div class="dropdown-content">
<a href="bubble.html">Bubble Sort</a>
</div>
</div>
</div>
<div class="w3-container">
<button class="w3-button w3-xlarge w3-circle w3-red w3-card-4" id="myBtn">+</button>
</div>
<!-- ENTER CONTENT HERE-->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<textarea rows="6" cols="50" placeholder="Give your reviews..." style="color:black"></textarea>
<span class="close">×</span>
<button class="button" type="button" onclick="submit()" style="height:45px;width:200px ;padding:10px;font-size: 18px"><span>Submit</span></button>
</div>
</div>
<div class="row">
<div class="leftcolumn">
<div class="card">
<h2><span style="margin-left: 80px"><b>Modular Addition , Subtraction and Multiplication</b></span></h2>
<h3 style="font-family: Raleway"><b><i>Adding Modular Expressions</i></b></h3>
<h4 style="font-family: Merriweather">(A + B) mod C = (A mod C + B mod C) mod C</h4>
<p>Example:
<br> Let A=14, B=17, C=5
<br> Let's verify: (A + B) mod C = (A mod C + B mod C) mod C
<br> LHS = Left Hand Side of the Equation
<br> RHS = Right Hand Side of the Equation
<br> LHS = (A + B) mod C
<br> LHS = (14 + 17) mod 5
<br> LHS = 31 mod 5
<br> LHS = 1
<br> RHS = (A mod C + B mod C) mod C
<br> RHS = (14 mod 5 + 17 mod 5) mod 5
<br> RHS = (4 + 2) mod 5
<br> RHS = 1
<br> LHS = RHS = 1
<br>
</p>
<p>Visualisation of Modular addition:
<br>
</p>
<div style="margin-left: 250px"><img src="css//img//3a2cb32acda2b6b63f88c61b8def97c0c1185767.jpg" alt="Mod Clock"></div>
<h3 style="font-family: Raleway"><b><i>Subtacting Modular Expressions</i></b></h3>
<p>The same concept is used while subtracting the modular expressions.
<br>
</p>
<h4 style="font-family: Merriweather">(A - B) mod C = (A mod C - B mod C) mod C</h4>
<h3 style="font-family: Raleway"><b><i>Multiplying Modular Expressions</i></b></h3>
<p>The same concept is used while multiplying the modular expressions.
<br>
</p>
<h4 style="font-family: Merriweather">(A * B) mod C = (A mod C * B mod C) mod C</h4>
<p style="padding-left: 800px;font-size: 10px"><i>Source : KhanAcademy.com</i></p>
</div>
<div class="card">
<h2>Mod Addition</h2>
<br>
<br>
<div style="margin-left: 250px">
<form>
<input type="number" id="val1" placeholder="Enter A" required>
<input type="number" id="val2" placeholder="Enter B" required>
<input type="number" id="val3" placeholder="Enter C" required>
</form>
<br>
<p>
<button style="margin-left: 50px" class="button" onclick="Mod_add()">Get Mod</button>
<p id="answ" style="font-family: Merriweather;margin-left: 100px"><b></b></p>
</div>
</div>
<div class="card">
<h2>Mod Subtraction</h2>
<br>
<br>
<div style="margin-left: 250px">
<form>
<input type="number" id="sub1" placeholder="Enter A" required>
<input type="number" id="sub2" placeholder="Enter B" required>
<input type="number" id="sub3" placeholder="Enter C" required>
</form>
<br>
<p>
<button style="margin-left: 50px" class="button" onclick="Mod_sub()">Get Mod</button>
<p id="an" style="font-family: Merriweather;margin-left: 100px"><b></b></p>
</div>
</div>
<div class="card">
<h2>Mod Multiplication</h2>
<br>
<br>
<div style="margin-left: 250px">
<form>
<input type="number" id="mul1" placeholder="Enter A" required>
<input type="number" id="mul2" placeholder="Enter B" required>
<input type="number" id="mul3" placeholder="Enter C" required>
</form>
<br>
<p>
<button style="margin-left: 50px" class="button" onclick="Mod_multi()">Get Mod</button>
<p id="answer" style="font-family: Merriweather;margin-left: 100px"><b></b></p>
</div>
</div>
</div>
<div class="sticky">
<div class="card">
<h2 style="font-family: Merriweather">References</h2>
<div>
<a href="https://ocw.mit.edu/courses/mathematics/18-785-number-theory-i-fall-2016/"><img src="css//img//mitocw_1024x768.jpg" alt="mitocw" style="height: 200px ; width: 200px"></a>
</div>
<p>MIT OpenCourseWare By Prof.Andrew Sutherland</p>
<a href="https://ocw.mit.edu/courses/mathematics/18-785-number-theory-i-fall-2016/">
<button class="button" id="mit"><span>Visit </span></button>
</a>
</div>
</div>
</div>
<!-- CUSTOM JS GOES HERE -->
<script src="js/prim.js"></script>
<script type="text/javascript">
function openNav() {
document.getElementById("mySidenav").style.width = "15%";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
</body>
</html>