-
Notifications
You must be signed in to change notification settings - Fork 39
/
CONTFRAC.HTM
583 lines (583 loc) · 44.3 KB
/
CONTFRAC.HTM
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
<!doctype html>
<html lang="en" prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#">
<head>
<meta charset="utf-8">
<meta name="Author" content="Dario Alejandro Alpern">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Web application that finds the continued fraction representation of rational numbers and quadratic irrationalities. Written by Dario Alpern.">
<meta name="theme-color" content="#db5945">
<meta name="twitter:card" content="summary_large_image">
<meta property="og:title" content="Continued fraction calculator">
<meta property="og:type" content="article">
<meta property="og:site_name" content="Alpertron">
<meta property="og:url" content="https://www.alpertron.com.ar/CONTFRAC.HTM">
<meta property="og:image" content="https://www.alpertron.com.ar/contfrac.png">
<meta property="og:image:width" content="893">
<meta property="og:image:height" content="469">
<meta property="og:image:alt" content="Screenshot">
<meta property="og:locale" content="en_US">
<meta property="og:locale:alternate" content="es_ES">
<meta property="og:description" content="This finds the continued fraction representation of rational numbers and quadratic irrationalities.">
<meta property="article:published_time" content="2024-11-04">
<meta property="fb:app_id" content="1495228927625175">
<link rel="manifest" href="contfrac.webmanifest">
<link rel="alternate" hreflang="es" href="https://www.alpertron.com.ar/FRACCONT.HTM">
<link rel="alternate" hreflang="en" href="https://www.alpertron.com.ar/CONTFRAC.HTM">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="contfrac-icon-180px.png">
<link rel="canonical" href="https://www.alpertron.com.ar/CONTFRAC.HTM">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Q7PH40GPHC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-Q7PH40GPHC');
</script>
<title>Continued fraction calculator</title>
<style>
@media screen {
nav {background-color:#000080; width:100%; margin:0px; text-align:center}
nav ul {padding:0; margin:0 auto; list-style:none; display:inline-block}
nav li {float:left; position:relative; display:block; margin-top:0px; margin-bottom:0px; margin-left:5px; margin-right:5px; background-color:#000080; color:#FFFFFF; cursor: pointer; text-align:left}
nav li[aria-expanded="true"] {background-color:#004000; color:#FFFFFF}
nav li ul {display:none; position:absolute}
nav li[aria-expanded="true"] ul.alignleft {display:block; height:auto}
nav li[aria-expanded="true"] ul.alignright {display:block; height:auto; right:0px; background-color:#004000}
nav li ul li {clear:both; white-space: nowrap; border:0px; background-color:#004000; width:100%; padding-top:1em; padding-bottom:0.5em}
nav a:link{color:#FFFFFF; text-decoration:none}
nav a:visited{color:#FFFFFF; text-decoration:none}
nav a:hover{background-color:#004000; color:#FFFFFF; text-decoration:none}
nav a:active{background-color:#004000; color:#FFFFFF; text-decoration:none}
nav li ul li a:link{background-color:#004000; color:#FFFFFF; display:block; width:100%}
nav li ul li a:visited{background-color:#004000;color:#FFFFFF; display:block; width:100%}
nav li ul li a:hover{background-color:#FFFFFF; color:#004000; display:block; width:100%}
nav li ul li a:active{background-color:#FFFFFF; color:#004000; display:block; width:100%}
nav::after {clear:both}
.inputfbck{width: calc(100% - 10em);float:right;padding:3px;margin:0px;}
@media (max-width: 400px) { nav { font-size:0.7em;} }
@media (min-width: 400px) { nav { font-size:1em;} }
@media (min-width: 500px) {#formleft {float:left;width:50%;} #formright {float:right;width:50%;}}
}
@media print {nav, #footer {display:none;}}
.modal-header {padding: 2px 10px; background-color: #5cb85c; color: white}
.modal-body {padding: 2px 10px}
.modal-content {
position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
background-color: #fefefe;
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
input[type=text], input[type=email], input[type=number] {min-height:2em; border-radius:10px}
input[type=button], button {min-height:2.5em; min-width:2.5em; border-radius:5px}
#close {float:right}
#modal-header-text {font-size:1.5em}
.hex {font-family: Courier, "Lucida Console", monospace}
#sending, #sentOK, #notSent {display:none}
.center {text-align:center}
#skip a {padding:6px; position:absolute; top:-40px; left:0px; color:white; border-right:1px solid white; border-bottom:1px solid white; border-bottom-right-radius:8px; background:#BF1722; transition:top 1s ease-out; z-index:100}
#skip a:focus {position:absolute; left:0px; top:0px; outline-color:transparent; transition: top .1s ease-in}
.bread {padding:0px;list-style:none; display:inline-block}
.bread li {display:inline}
.bread li+li:before {content:"›"}
body {font-family:Arial, sans-serif; margin:0; padding:0}
main {padding:10px}
h1, .h2title {text-align:center}
#actions button {color: white; background-color: #3b3b3b; min-height:100%; border-radius:10px}
#actbtn {display:flex; flex-flow:row wrap; justify-content:space-around; min-height:3em; margin-bottom:1em}
#funcbtns {display:flex; justify-content:space-around; flex-flow:row wrap; margin-top:3px; margin-bottom:3px}
#funcbtns button {min-height:2.5em; min-width:2.5em; margin:3px}
fieldset {border-radius:10px}
.mysvg {margin:0px;padding:0px;grid-column:1/3; grid-row:1}
.input{width: calc(100% - 3em);float:right;padding:3px;margin:0px}
.lf,.labels {padding:0.2em; clear:both; width:100%}
.bold {font-weight: bold; color:blue}
.new {color: #0000FF; font-weight:bold}
.applet {margin-left: auto;margin-right: auto; border: 0px none;width:90%;text-align:center;background-color:#c0c0c0;padding:10px;border-radius:10px}
#valueapp {display:grid}
#feedback, #cont {display:none}
.fraction {display: inline-block; vertical-align: middle; margin: 0 0.2em 0.4ex; text-align: center}
.fraction > span {display: block; padding-top: 0.15em}
.fraction span.fdn {border-top: thin solid black}
.fraction span.bar {display:none}
.sqrtout {white-space: nowrap}
.sqrtout:before {content: "√"}
.sqrtin {text-decoration:overline}
.offscr {position:absolute;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);padding:0;border:0;height:1px;width:1px;overflow:hidden;}
.atright {float:right}
#digits {max-width:6em}
@media (max-width: 53em) {
#actions {grid-column:1/3; grid-row:2}
#inputs {grid-column:1/3; grid-row:3}
#functions {grid-column:1/3; grid-row:4}
}
@media (min-width: 53em) {
#inputs {grid-column:1/3; grid-row:2}
#actions {grid-column:1; grid-row:3; width:320px}
#functions {grid-column:2/3; grid-row:3}
}
@media screen and (prefers-color-scheme: dark) {
body {color: #ddd; background-color: #121212}
.applet {background-color:#606060; color: #fff}
a {color: #a3d4a7}
a:link,a:active {color: #a3d4a7}
a:hover {color: #f5cba7}
a:visited {color: #d7bde2}
input, textarea {color: white; background-color: #3b3b3b}
button:disabled {color: #808080; background-color: #606060}
.fraction span.fdn {border-top: thin solid #eee}
.bold {color:yellow}
svg {fill:white}
.new {color: #E0E000}
}
</style>
<noscript>
<style>
.applet {display:none}
</style>
</noscript>
</head>
<body>
<div id="skip"><a href="#main">Skip to main content</a></div>
<nav aria-label="Main navigation">
<ul role="menubar">
<li role="menuitem" aria-haspopup="true" aria-expanded="false" tabindex="0">Electronics
<ul role="menu" class="alignleft popup">
<li role="menuitem"><a href="INTEL.HTM" hreflang="es" title="All Intel microprocessors from the 4004 up to Pentium (Spanish only)">Intel Microprocessors</a></li>
</ul>
</li>
<li role="menuitem" aria-haspopup="true" aria-expanded="false" tabindex="-1">Mathematics
<ul role="menu" class="alignleft popup">
<li role="menuitem"><a href="CALTORS.HTM" title="Web applications with JavaScript and WebAssembly implementing calculators">Calculators</a></li>
<li role="menuitem"><a href="NUMBERT.HTM" title="Articles and programs about number theory">Number Theory</a></li>
<li role="menuitem"><a href="PROBLEMS.HTM" title="Interesting math problems">Problems</a></li>
</ul>
</li>
<li role="menuitem" aria-haspopup="true" aria-expanded="false" tabindex="-1">Programs
<ul role="menu" class="alignright popup">
<li role="menuitem"><a href="ASSEM386.HTM" title="Programs written in 80386 Assembler">Assembler 80386</a></li>
<li role="menuitem"><a href="JAVAPROG.HTM" title="Web applications with JavaScript and WebAssembly">Web applications</a></li>
<li role="menuitem"><a href="GAMES.HTM" title="Computer games">Games</a></li>
</ul>
</li>
<li class="alignright" role="menuitem" aria-haspopup="true" aria-expanded="false" tabindex="-1">Contact
<ul role="menu" class="alignright popup">
<li role="menuitem"><a href="EPERS.HTM" title="Personal information">Personal</a></li>
<li role="menuitem"><a href="FORM.HTM" title="Form to send comments">Comments</a></li>
<li role="menuitem"><a href="EGBOOK.HTM" title="Old and new guestbook">Guestbook</a></li>
<li role="menuitem"><a href="PRIVACY.HTM" title="Privacy Policy">Privacy</a></li>
<li role="menuitem"><a href="DONATION.HTM" title="Donations to the author of this Web site">Donations</a></li>
</ul>
</li>
</ul>
<ul class="atright"><li><a href="FRACCONT.HTM" hreflang="es" title="Esta página Web en español">ESP</a></li></ul>
</nav>
<main id="main">
<article>
<h1>Continued Fraction calculator</h1>
<ol class="bread" vocab="https://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="ENGLISH.HTM"><span property="name">Alpertron</span></a>
<meta property="position" content="1">
</li>
<li property="itemListElement" typeof="ListItem">
<a property="item" typeof="WebPage" href="JAVAPROG.HTM"><span property="name">Web applications</span></a>
<meta property="position" content="2">
</li>
<li property="itemListElement" typeof="ListItem">
<span property="name">Continued Fraction calculator</span>
<meta property="position" content="3">
</li>
</ol>
<noscript><p><strong>The calculator does not work with Javascript disabled. Please check your browser settings.</strong></p></noscript>
<div class="applet" id="valueapp">
<p class="mysvg">
<svg height="30.4592pt" version="1.1" viewbox="0 0 40.118 30.4592" width="40.118pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M3.612 -1.428C3.552 -1.224 3.552 -1.2 3.384 -0.972C3.12 -0.636 2.592 -0.12 2.028 -0.12C1.536 -0.12 1.26 -0.564 1.26 -1.272C1.26 -1.932 1.632 -3.276 1.86 -3.78C2.268 -4.62 2.832 -5.052 3.3 -5.052C4.092 -5.052 4.248 -4.068 4.248 -3.972C4.248 -3.96 4.212 -3.804 4.2 -3.78L3.612 -1.428ZM4.38 -4.5C4.248 -4.812 3.924 -5.292 3.3 -5.292C1.944 -5.292 0.48 -3.54 0.48 -1.764C0.48 -0.576 1.176 0.12 1.992 0.12C2.652 0.12 3.216 -0.396 3.552 -0.792C3.672 -0.084 4.236 0.12 4.596 0.12S5.244 -0.096 5.46 -0.528C5.652 -0.936 5.82 -1.668 5.82 -1.716C5.82 -1.776 5.772 -1.824 5.7 -1.824C5.592 -1.824 5.58 -1.764 5.532 -1.584C5.352 -0.876 5.124 -0.12 4.632 -0.12C4.284 -0.12 4.26 -0.432 4.26 -0.672C4.26 -0.948 4.296 -1.08 4.404 -1.548C4.488 -1.848 4.548 -2.112 4.644 -2.46C5.088 -4.26 5.196 -4.692 5.196 -4.764C5.196 -4.932 5.064 -5.064 4.884 -5.064C4.5 -5.064 4.404 -4.644 4.38 -4.5Z" id="ltr-a"/>
<path d="M2.772 -8.028C2.784 -8.076 2.808 -8.148 2.808 -8.208C2.808 -8.328 2.688 -8.328 2.664 -8.328C2.652 -8.328 2.22 -8.292 2.004 -8.268C1.8 -8.256 1.62 -8.232 1.404 -8.22C1.116 -8.196 1.032 -8.184 1.032 -7.968C1.032 -7.848 1.152 -7.848 1.272 -7.848C1.884 -7.848 1.884 -7.74 1.884 -7.62C1.884 -7.536 1.788 -7.188 1.74 -6.972L1.452 -5.82C1.332 -5.34 0.648 -2.616 0.6 -2.4C0.54 -2.1 0.54 -1.896 0.54 -1.74C0.54 -0.516 1.224 0.12 2.004 0.12C3.396 0.12 4.836 -1.668 4.836 -3.408C4.836 -4.512 4.212 -5.292 3.312 -5.292C2.688 -5.292 2.124 -4.776 1.896 -4.536L2.772 -8.028ZM2.016 -0.12C1.632 -0.12 1.212 -0.408 1.212 -1.344C1.212 -1.74 1.248 -1.968 1.464 -2.808C1.5 -2.964 1.692 -3.732 1.74 -3.888C1.764 -3.984 2.472 -5.052 3.288 -5.052C3.816 -5.052 4.056 -4.524 4.056 -3.9C4.056 -3.324 3.72 -1.968 3.42 -1.344C3.12 -0.696 2.568 -0.12 2.016 -0.12Z" id="ltr-b"/>
<path d="M4.692 -4.512C4.464 -4.512 4.356 -4.512 4.188 -4.368C4.116 -4.308 3.984 -4.128 3.984 -3.936C3.984 -3.696 4.164 -3.552 4.392 -3.552C4.68 -3.552 5.004 -3.792 5.004 -4.272C5.004 -4.848 4.452 -5.292 3.624 -5.292C2.052 -5.292 0.48 -3.576 0.48 -1.872C0.48 -0.828 1.128 0.12 2.352 0.12C3.984 0.12 5.016 -1.152 5.016 -1.308C5.016 -1.38 4.944 -1.44 4.896 -1.44C4.86 -1.44 4.848 -1.428 4.74 -1.32C3.972 -0.3 2.832 -0.12 2.376 -0.12C1.548 -0.12 1.284 -0.84 1.284 -1.44C1.284 -1.86 1.488 -3.024 1.92 -3.84C2.232 -4.404 2.88 -5.052 3.636 -5.052C3.792 -5.052 4.452 -5.028 4.692 -4.512Z" id="ltr-c"/>
<path d="M4.788 -2.772H8.1C8.268 -2.772 8.484 -2.772 8.484 -2.988C8.484 -3.216 8.28 -3.216 8.1 -3.216H4.788V-6.528C4.788 -6.696 4.788 -6.912 4.572 -6.912C4.344 -6.912 4.344 -6.708 4.344 -6.528V-3.216H1.032C0.864 -3.216 0.648 -3.216 0.648 -3C0.648 -2.772 0.852 -2.772 1.032 -2.772H4.344V0.54C4.344 0.708 4.344 0.924 4.56 0.924C4.788 0.924 4.788 0.72 4.788 0.54V-2.772Z" id="plus"/>
<path d="M4.668 10.26L2.556 5.592C2.472 5.4 2.412 5.4 2.376 5.4C2.364 5.4 2.304 5.4 2.172 5.496L1.032 6.36C0.876 6.48 0.876 6.516 0.876 6.552C0.876 6.612 0.912 6.684 0.996 6.684C1.068 6.684 1.272 6.516 1.404 6.42C1.476 6.36 1.656 6.228 1.788 6.132L4.152 11.328C4.236 11.52 4.296 11.52 4.404 11.52C4.584 11.52 4.62 11.448 4.704 11.28L10.152 0C10.236 -0.168 10.236 -0.216 10.236 -0.24C10.236 -0.36 10.14 -0.48 9.996 -0.48C9.9 -0.48 9.816 -0.42 9.72 -0.228L4.668 10.26Z" id="sqrt"/>
</defs>
<g id="page1" transform="matrix(1.12578 0 0 1.12578 -65.342 -61.5624)">
<use x="57.8248" xlink:href="#ltr-a" y="65.1866"/>
<use x="66.6594" xlink:href="#plus" y="65.1866"/>
<use x="78.4648" xlink:href="#sqrt" y="54.96"/>
<rect height="0.47998" width="4.99576" x="88.4649" y="54.48"/>
<use x="88.4649" xlink:href="#ltr-b" y="65.1866"/>
<rect height="0.47998" width="35.6358" x="57.8248" y="70.0647"/>
<use x="73.1143" xlink:href="#ltr-c" y="81.5361"/>
</g>
</svg>
</p>
<div id="inputs">
<label for="num">a</label><input type="text" inputmode="numeric" id="num" value="" class="input" aria-label="numerator">
<div class="lf"></div>
<label for="delta">b</label><input type="text" inputmode="numeric" id="delta" value="" class="input" aria-label="radicand">
<div class="lf"></div>
<label for="den">c</label><input type="text" inputmode="numeric" id="den" value="" class="input" aria-label="denominator">
</div>
<fieldset id="actions"><legend>Actions</legend>
<div id="actbtn">
<button type="button" id="calc" title="Show the continued fraction for the requested number">Continued<br>fraction</button>
<button type="button" id="config" title="Change parameters used in the application">Config</button>
<button type="button" id="helpbtn" title="Read information about this calculator">Help</button>
<button type="button" id="clrinput" title="Erase input boxes contents">Clear<br>input</button>
</div>
<input type="checkbox" id="converg"><label for="converg" title="Show the best approximations as rational number for the requested number">Show convergents</label>
</fieldset>
<fieldset id="functions"><legend>Functions</legend>
<label for="funccat">Category:</label>
<select id="funccat">
<optgroup label="Functions or operators">
<option value="0" selected>Basic Math</option>
<option value="1">Comparisons</option>
<option value="2">Logic</option>
<option value="3">Divisibility</option>
<option value="4">Recreational Math</option>
<option value="5">Number Theory</option>
<option value="6">Other</option>
</optgroup>
</select>
<div id="funcbtns">
<button type="button">(</button><button type="button">)</button><button type="button">+</button><button type="button">-</button><button type="button">*</button><button type="button">/</button><button type="button">%</button><button type="button">^</button><button type="button">ans</button><button type="button">sqrt(</button><button type="button">iroot(</button><button type="button">Random(</button><button type="button">Abs(</button><button type="button">Sign(</button>
</div>
</fieldset>
</div>
<div id="help" aria-live="polite">
<p>This Web application shows the continued fraction expansion of rational numbers and quadratic irrationalities.</p>
<p>Any real number <var>x</var> can be represented uniquely by a continued fraction:</p>
<p class="mysvg">
<span class="offscr">x is equal to a sub 0 plus 1 over a sub 1 plus 1 over a sub 2 plus 1 over a sub 3 plus etcetera</span>
<svg height="76.6988pt" version="1.1" viewbox="0 0 159.224 76.6988" width="159.224pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M5.688 -4.896C5.304 -4.824 5.16 -4.536 5.16 -4.308C5.16 -4.02 5.388 -3.924 5.556 -3.924C5.916 -3.924 6.168 -4.236 6.168 -4.56C6.168 -5.064 5.592 -5.292 5.088 -5.292C4.356 -5.292 3.948 -4.572 3.84 -4.344C3.564 -5.244 2.82 -5.292 2.604 -5.292C1.38 -5.292 0.732 -3.72 0.732 -3.456C0.732 -3.408 0.78 -3.348 0.864 -3.348C0.96 -3.348 0.984 -3.42 1.008 -3.468C1.416 -4.8 2.22 -5.052 2.568 -5.052C3.108 -5.052 3.216 -4.548 3.216 -4.26C3.216 -3.996 3.144 -3.72 3 -3.144L2.592 -1.5C2.412 -0.78 2.064 -0.12 1.428 -0.12C1.368 -0.12 1.068 -0.12 0.816 -0.276C1.248 -0.36 1.344 -0.72 1.344 -0.864C1.344 -1.104 1.164 -1.248 0.936 -1.248C0.648 -1.248 0.336 -0.996 0.336 -0.612C0.336 -0.108 0.9 0.12 1.416 0.12C1.992 0.12 2.4 -0.336 2.652 -0.828C2.844 -0.12 3.444 0.12 3.888 0.12C5.112 0.12 5.76 -1.452 5.76 -1.716C5.76 -1.776 5.712 -1.824 5.64 -1.824C5.532 -1.824 5.52 -1.764 5.484 -1.668C5.16 -0.612 4.464 -0.12 3.924 -0.12C3.504 -0.12 3.276 -0.432 3.276 -0.924C3.276 -1.188 3.324 -1.38 3.516 -2.172L3.936 -3.804C4.116 -4.524 4.524 -5.052 5.076 -5.052C5.1 -5.052 5.436 -5.052 5.688 -4.896Z" id="let-x"/>
<path d="M2.208 -0.588C2.208 -0.912 1.932 -1.164 1.632 -1.164C1.284 -1.164 1.044 -0.888 1.044 -0.588C1.044 -0.228 1.344 0 1.62 0C1.944 0 2.208 -0.252 2.208 -0.588Z" id="dot2"/>
<path d="M3.456 -7.692C3.456 -7.968 3.456 -7.98 3.216 -7.98C2.928 -7.656 2.328 -7.212 1.092 -7.212V-6.864C1.368 -6.864 1.968 -6.864 2.628 -7.176V-0.924C2.628 -0.492 2.592 -0.348 1.536 -0.348H1.164V0C1.488 -0.024 2.652 -0.024 3.048 -0.024S4.596 -0.024 4.92 0V-0.348H4.548C3.492 -0.348 3.456 -0.492 3.456 -0.924V-7.692Z" id="nbr-1"/>
<path d="M8.1 -3.888C8.268 -3.888 8.484 -3.888 8.484 -4.104C8.484 -4.332 8.28 -4.332 8.1 -4.332H1.032C0.864 -4.332 0.648 -4.332 0.648 -4.116C0.648 -3.888 0.852 -3.888 1.032 -3.888H8.1ZM8.1 -1.656C8.268 -1.656 8.484 -1.656 8.484 -1.872C8.484 -2.1 8.28 -2.1 8.1 -2.1H1.032C0.864 -2.1 0.648 -2.1 0.648 -1.884C0.648 -1.656 0.852 -1.656 1.032 -1.656H8.1Z" id="equal"/>
<path d="M3.912 -2.552C3.912 -3.408 3.824 -3.928 3.56 -4.44C3.208 -5.144 2.56 -5.32 2.12 -5.32C1.112 -5.32 0.744 -4.568 0.632 -4.344C0.344 -3.76 0.328 -2.968 0.328 -2.552C0.328 -2.024 0.352 -1.216 0.736 -0.576C1.104 0.016 1.696 0.168 2.12 0.168C2.504 0.168 3.192 0.048 3.592 -0.744C3.888 -1.32 3.912 -2.032 3.912 -2.552ZM2.12 -0.056C1.848 -0.056 1.296 -0.184 1.128 -1.024C1.04 -1.48 1.04 -2.232 1.04 -2.648C1.04 -3.2 1.04 -3.76 1.128 -4.2C1.296 -5.016 1.92 -5.096 2.12 -5.096C2.392 -5.096 2.944 -4.96 3.104 -4.232C3.2 -3.792 3.2 -3.192 3.2 -2.648C3.2 -2.176 3.2 -1.456 3.104 -1.008C2.936 -0.168 2.384 -0.056 2.12 -0.056Z" id="sub-0"/>
<path d="M2.512 -5.096C2.512 -5.312 2.496 -5.32 2.28 -5.32C1.952 -5 1.528 -4.808 0.768 -4.808V-4.544C0.984 -4.544 1.416 -4.544 1.88 -4.76V-0.656C1.88 -0.36 1.856 -0.264 1.096 -0.264H0.816V0C1.144 -0.024 1.832 -0.024 2.192 -0.024S3.248 -0.024 3.576 0V-0.264H3.296C2.536 -0.264 2.512 -0.36 2.512 -0.656V-5.096Z" id="sub-1"/>
<path d="M2.256 -1.632C2.384 -1.752 2.72 -2.016 2.848 -2.128C3.344 -2.584 3.816 -3.024 3.816 -3.752C3.816 -4.704 3.016 -5.32 2.016 -5.32C1.056 -5.32 0.424 -4.592 0.424 -3.88C0.424 -3.488 0.736 -3.432 0.848 -3.432C1.016 -3.432 1.264 -3.552 1.264 -3.856C1.264 -4.272 0.864 -4.272 0.768 -4.272C1 -4.856 1.536 -5.056 1.928 -5.056C2.672 -5.056 3.056 -4.424 3.056 -3.752C3.056 -2.92 2.472 -2.312 1.528 -1.344L0.52 -0.304C0.424 -0.216 0.424 -0.2 0.424 0H3.584L3.816 -1.432H3.568C3.544 -1.272 3.48 -0.872 3.384 -0.72C3.336 -0.656 2.728 -0.656 2.6 -0.656H1.176L2.256 -1.632Z" id="sub-2"/>
<path d="M2.024 -2.672C2.656 -2.672 3.056 -2.208 3.056 -1.368C3.056 -0.368 2.488 -0.072 2.064 -0.072C1.624 -0.072 1.024 -0.232 0.744 -0.656C1.032 -0.656 1.232 -0.84 1.232 -1.104C1.232 -1.36 1.048 -1.544 0.792 -1.544C0.576 -1.544 0.352 -1.408 0.352 -1.088C0.352 -0.328 1.168 0.168 2.08 0.168C3.144 0.168 3.888 -0.568 3.888 -1.368C3.888 -2.032 3.36 -2.64 2.544 -2.816C3.176 -3.04 3.648 -3.584 3.648 -4.224S2.928 -5.32 2.096 -5.32C1.24 -5.32 0.592 -4.856 0.592 -4.248C0.592 -3.952 0.792 -3.824 1 -3.824C1.248 -3.824 1.408 -4 1.408 -4.232C1.408 -4.528 1.152 -4.64 0.976 -4.648C1.312 -5.088 1.928 -5.112 2.072 -5.112C2.28 -5.112 2.888 -5.048 2.888 -4.224C2.888 -3.664 2.656 -3.328 2.544 -3.2C2.304 -2.952 2.12 -2.936 1.632 -2.904C1.48 -2.896 1.416 -2.888 1.416 -2.784C1.416 -2.672 1.488 -2.672 1.624 -2.672H2.024Z" id="sub-3"/>
</defs>
<g id="page2" transform="matrix(1.12578 0 0 1.12578 -63.986 -63.7508)">
<use x="56.6248" xlink:href="#let-x" y="73.1799"/>
<use x="66.6351" xlink:href="#equal" y="73.1799"/>
<use x="79.1072" xlink:href="#ltr-a" y="73.1799"/>
<use x="85.2752" xlink:href="#sub-0" y="74.9799"/>
<use x="92.6919" xlink:href="#plus" y="73.1799"/>
<use x="148.941" xlink:href="#nbr-1" y="64.1499"/>
<rect height="0.47998" width="92.3618" x="105.697" y="69.9399"/>
<use x="105.697" xlink:href="#ltr-a" y="91.0398"/>
<use x="111.865" xlink:href="#sub-1" y="92.8398"/>
<use x="119.282" xlink:href="#plus" y="91.0398"/>
<use x="162.236" xlink:href="#nbr-1" y="82.0098"/>
<rect height="0.47998" width="65.7717" x="132.287" y="87.7998"/>
<use x="132.287" xlink:href="#ltr-a" y="108.9"/>
<use x="138.455" xlink:href="#sub-2" y="110.7"/>
<use x="145.872" xlink:href="#plus" y="108.9"/>
<use x="175.531" xlink:href="#nbr-1" y="99.8696"/>
<rect height="0.47998" width="39.1816" x="158.877" y="105.66"/>
<use x="158.877" xlink:href="#ltr-a" y="122.746"/>
<use x="165.045" xlink:href="#sub-3" y="124.546"/>
<use x="172.462" xlink:href="#plus" y="122.746"/>
<use x="184.934" xlink:href="#dot2" y="115.746"/>
<use x="189.531" xlink:href="#dot2" y="118.746"/>
<use x="194.129" xlink:href="#dot2" y="121.746"/>
</g>
</svg>
</p>
<p>where <var>a</var><sub>1</sub>, <var>a</var><sub>2</sub>, <var>a</var><sub>3</sub>, ... are integer numbers greater than zero. A more compact representation is:</p>
<p class="mysvg">
<span class="offscr">x is equal to a sub 0 plus double slash a sub 1, a sub 2, a sub 3, etcetera double slash</span>
<svg id="cfrac" height="13.5093pt" version="1.1" viewbox="0 0 153.013 13.5093" width="153.013pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M2.34 0.048C2.34 -0.648 2.112 -1.164 1.62 -1.164C1.236 -1.164 1.044 -0.852 1.044 -0.588S1.224 0 1.632 0C1.788 0 1.92 -0.048 2.028 -0.156C2.052 -0.18 2.064 -0.18 2.076 -0.18C2.1 -0.18 2.1 -0.012 2.1 0.048C2.1 0.444 2.028 1.224 1.332 2.004C1.2 2.148 1.2 2.172 1.2 2.196C1.2 2.256 1.26 2.316 1.32 2.316C1.416 2.316 2.34 1.428 2.34 0.048Z" id="comma"/>
<path d="M5.148 -8.556C5.148 -8.568 5.22 -8.748 5.22 -8.772C5.22 -8.916 5.1 -9 5.004 -9C4.944 -9 4.836 -9 4.74 -8.736L0.72 2.556C0.72 2.568 0.648 2.748 0.648 2.772C0.648 2.916 0.768 3 0.864 3C0.936 3 1.044 2.988 1.128 2.736L5.148 -8.556Z" id="over"/>
<path d="M2.304 -3C2.304 -3.348 2.016 -3.636 1.668 -3.636S1.032 -3.348 1.032 -3S1.32 -2.364 1.668 -2.364S2.304 -2.652 2.304 -3Z" id="dot"/>
</defs>
<g id="page3" transform="matrix(1.12578 0 0 1.12578 -63.986 -64.41)">
<use x="56.6248" xlink:href="#let-x" y="66"/>
<use x="66.6351" xlink:href="#equal" y="66"/>
<use x="79.1072" xlink:href="#ltr-a" y="66"/>
<use x="85.2752" xlink:href="#sub-0" y="67.8"/>
<use x="92.6919" xlink:href="#plus" y="66"/>
<use x="104.497" xlink:href="#over" y="66"/>
<use x="110.372" xlink:href="#over" y="66"/>
<use x="116.247" xlink:href="#ltr-a" y="66"/>
<use x="122.415" xlink:href="#sub-1" y="67.8"/>
<use x="127.165" xlink:href="#comma" y="66"/>
<use x="132.429" xlink:href="#ltr-a" y="66"/>
<use x="138.597" xlink:href="#sub-2" y="67.8"/>
<use x="143.347" xlink:href="#comma" y="66"/>
<use x="148.611" xlink:href="#ltr-a" y="66"/>
<use x="154.779" xlink:href="#sub-3" y="67.8"/>
<use x="159.529" xlink:href="#comma" y="66"/>
<use x="164.793" xlink:href="#dot" y="66"/>
<use x="170.126" xlink:href="#dot" y="66"/>
<use x="175.459" xlink:href="#dot" y="66"/>
<use x="180.793" xlink:href="#over" y="66"/>
<use x="186.668" xlink:href="#over" y="66"/>
</g>
</svg>
</p>
<p>
If the number to be represented is rational, there is a finite number of terms in the continued fraction. If the number is a quadratic irrationality of the form <span class="offscr">fraction whether the numerator is a plus the square root of b and the denominator is c</span>
<svg height="16.0902pt" version="1.1" viewbox="0 0 62.7131 16.0902" width="62.7131pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M3.9 2.916C3.9 2.88 3.9 2.856 3.696 2.652C2.496 1.44 1.824 -0.54 1.824 -2.988C1.824 -5.316 2.388 -7.32 3.78 -8.736C3.9 -8.844 3.9 -8.868 3.9 -8.904C3.9 -8.976 3.84 -9 3.792 -9C3.636 -9 2.652 -8.136 2.064 -6.96C1.452 -5.748 1.176 -4.464 1.176 -2.988C1.176 -1.92 1.344 -0.492 1.968 0.792C2.676 2.232 3.66 3.012 3.792 3.012C3.84 3.012 3.9 2.988 3.9 2.916Z" id="lpar"/>
<path d="M3.384 -2.988C3.384 -3.9 3.264 -5.388 2.592 -6.78C1.884 -8.22 0.9 -9 0.768 -9C0.72 -9 0.66 -8.976 0.66 -8.904C0.66 -8.868 0.66 -8.844 0.864 -8.64C2.064 -7.428 2.736 -5.448 2.736 -3C2.736 -0.672 2.172 1.332 0.78 2.748C0.66 2.856 0.66 2.88 0.66 2.916C0.66 2.988 0.72 3.012 0.768 3.012C0.924 3.012 1.908 2.148 2.496 0.972C3.108 -0.252 3.384 -1.548 3.384 -2.988Z" id="rpar"/>
</defs>
<g id="page4" transform="matrix(1.12578 0 0 1.12578 -63.986 -61.8195)">
<use x="56.6248" xlink:href="#lpar" y="66"/>
<use x="61.1942" xlink:href="#ltr-a" y="66"/>
<use x="70.0288" xlink:href="#plus" y="66"/>
<use x="81.8342" xlink:href="#sqrt" y="55.1875"/>
<rect height="0.47998" width="4.99576" x="91.8343" y="54.7075"/>
<use x="91.8343" xlink:href="#ltr-b" y="66"/>
<use x="96.83" xlink:href="#rpar" y="66"/>
<use x="101.399" xlink:href="#over" y="66"/>
<use x="107.274" xlink:href="#ltr-c" y="66"/>
</g>
</svg>,
then the continued fraction is periodic. This calculator can find the continued fraction expansions of rational numbers and quadratic irrationalities.
Apart from the coefficients <var>a</var><sub><var>n</var></sub>, the program allows to find the convergent <var>A</var><sub><var>n</var></sub>/<var>B</var><sub><var>n</var></sub>. This quotient
is the best rational approximation to the argument x with denominator less or equal to B<sub>n</sub> and matches the value obtained by developing only the first <var>n</var> coefficients of the continued fraction.
</p>
<p>You can type numbers or numerical expressions on the input boxes.</p>
<p>The calculator accepts numbers of up to 10000 digits.</p>
<p>
If you need the square root to subtract the number at the left, just negate both <var>a</var> and <var>c</var>.
</p>
<p>
If <var>b</var> is negative, the result is not a real number, so it cannot be represented as a continued fraction.</p>
<p>For rational numbers the calculator finds the coefficients and the numerator and denominator of all convergents, but for quadratic irrationalities the calculator stops after the 100000th convergent if the period is larger. When the program displays convergents, it stops before if it runs out of memory.</p>
<h2>Expressions</h2>
<p>You can use the following operators and parentheses for the expressions:
</p>
<ul>
<li> + for addition</li>
<li> - for subtraction</li>
<li> * for multiplication</li>
<li> / for integer division</li>
<li> % for modulus (remainder of the integer division)</li>
<li> ^ or ** for exponentiation (the exponent must be greater than or equal to zero).</li>
<li> <strong><</strong>, <strong>==</strong>, <strong>></strong>; <strong><=</strong>, <strong>>=</strong>, != for comparisons. The operators return zero for false and -1 for true.</li>
<li> <strong>Ans</strong>: retrieves the last answer.</li>
<li> <strong>AND</strong>, <strong>OR</strong>, <strong>XOR</strong>, <strong>NOT</strong> for binary logic. The operations are done in binary (base 2). Positive (negative) numbers are prepended with an infinite number of bits set to zero (one).</li>
<li> <strong>SHL</strong> or <strong><<</strong>: When <var>b</var> ≥ 0, <var>a</var> SHL <var>b</var> shifts <var>a</var> left the number of bits specified by <var>b</var>. This is equivalent to <var>a</var> × 2<sup><var>b</var></sup>. Otherwise, <var>a</var> SHL <var>b</var> shifts <var>a</var> right the number of bits specified by −<var>b</var>. This is equivalent to floor(<var>a</var> / 2<sup>−<var>b</var></sup>). Example: 5 SHL 3 = 40.</li>
<li> <strong>SHR</strong> or <strong>>></strong>: When <var>b</var> ≥ 0, <var>a</var> SHR <var>b</var> shifts <var>a</var> right the number of bits specified by <var>b</var>. This is equivalent to floor(<var>a</var> / 2<sup><var>b</var></sup>). Otherwise, <var>a</var> SHR <var>b</var> shifts <var>a</var> left the number of bits specified by −<var>b</var>. This is equivalent to <var>a</var> × 2<sup>−<var>b</var></sup>. Example: -19 SHR 2 = -5.</li>
<li> <strong>n!</strong>: factorial (<var>n</var> must be greater than or equal to zero). Example: 6! = 6 × 5 × 4 × 3 × 2 = 720.</li>
<li> <strong>n!! ... !</strong>: multiple factorial (<var>n</var> must be greater than or equal to zero). It is the product of <var>n</var> times <var>n</var> − <var>k</var> times <var>n</var> − <var>2k</var> ... (all numbers greater than zero) where <var>k</var> is the number of exclamation marks. Example: 7!! = 7 × 5 × 3 × 1 = 105.</li>
<li> <strong>p#</strong>: primorial (product of all primes less or equal than <var>p</var>). Example: 12# = 11 × 7 × 5 × 3 × 2 = 2310.</li>
<li> <strong>B(n)</strong>: Previous probable prime before <em>n</em>. Example: B(24) = 23.</li>
<li> <strong>F(n)</strong>: Fibonacci number F<sub>n</sub> from the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, etc. where each element equals the sum of the previous two members of the sequence. Example: F(7) = 13.</li>
<li> <strong>L(n)</strong>: Lucas number L<sub>n</sub> = F<sub><var>n</var>-1</sub> + F<sub><var>n</var>+1</sub></li>
<li> <strong>N(n)</strong>: Next probable prime after <em>n</em>. Example: N(24) = 29.</li>
<li> <strong>P(n)</strong>: Unrestricted Partition Number (number of decompositions of <var>n</var> into sums of integers without regard to order). Example: P(4) = 5 because the number 4 can be partitioned in 5 different ways: 4 = 3+1 = 2+2 = 2+1+1 = 1+1+1+1.</li>
<li> <strong>Gcd(m,n, ...)</strong>: Greatest common divisor of these integers. Example: GCD(12, 16) = 4.</li>
<li> <strong>Lcm(m,n, ...)</strong>: Least common multiple of these integers. Example: LCM(12, 16, 24) = 48.</li>
<li> <strong>FloorDiv(m,n)</strong>: integer part of the quotient of <var>m</var> divided by <var>n</var>. Examples: floordiv(10, 7) = 1 and floordiv(-10, 7) = -2.</li>
<li> <strong>Mod(m,n)</strong>: value of <var>m</var> modulo the absolute value of <var>n</var>. Examples: Mod(10, 7) = 3 and Mod(-10, 7) = 4.</li>
<li> <strong>Modinv(m,n)</strong>: inverse of <var>m</var> modulo <var>n</var>, only valid when <var>m</var> and <var>n</var> are coprime, meaning that they do not have common factors. Example: Modinv(3,7) = 5 because 3 × 5 ≡ 1 (mod 7)</li>
<li> <strong>Modpow(m,n,r)</strong>: finds <var>m</var><sup><var>n</var></sup> modulo <var>r</var>. Example: Modpow(3, 4, 7) = 4, because 3<sup>4</sup> ≡ 4 (mod 7).</li>
<li> <strong>Jacobi(m,n)</strong>: obtains the Jacobi symbol of <var>m</var> and <var>n</var>. When the second argument is prime, the result is zero when <var>m</var> is multiple of <var>n</var>, it is one if there is a solution of <var>x</var>² ≡ <var>m</var> (mod <var>n</var>) and it is equal to −1 when the mentioned congruence has no solution.</li>
<li> <strong>Random(m,n)</strong>: integer random number between <var>m</var> and <var>n</var>.</li>
<li> <strong>Abs(n)</strong>: absolute value of <var>n</var>.</li>
<li> <strong>Sign(n)</strong>: returns zero if <var>n</var> is zero, −1 if negative or 1 if positive.</li>
<li> <strong>IsPrime(n)</strong>: returns zero if <var>n</var> is not probable prime, -1 if it is. Example: IsPrime(5) = -1.</li>
<li> <strong>Sqrt(n)</strong>: Integer part of the square root of the argument.</li>
<li> <strong>Iroot(n,r)</strong>: Integer r-root of the first argument. Example: Iroot(8, 3) = 2.</li>
<li> <strong>NumDigits(n,r)</strong>: Number of digits of <var>n</var> in base <var>r</var>. Example: NumDigits(13, 2) = 4 because 13 in binary (base 2) is expressed as 1101.</li>
<li> <strong>SumDigits(n,r)</strong>: Sum of digits of <var>n</var> in base <var>r</var>. Example: SumDigits(213, 10) = 6 because the sum of the digits expressed in decimal is 2+1+3 = 6.</li>
<li> <strong>RevDigits(n,r)</strong>: finds the value obtained by writing backwards the digits of <var>n</var> in base <var>r</var>. Example: RevDigits(213, 10) = 312.</li>
</ul>
<p>You can use the prefix <em>0x</em> for hexadecimal numbers, for example 0x38 is equal to 56.</p>
<h2>Configuration</h2>
<p>You can change settings for this application by pressing the Config button when a factorization is not in progress. A new window will pop up where you can select different settings:</p>
<ul>
<li><strong>Digits per group</strong>: In order to improve readability, big numbers are separated by spaces forming groups of a fixed number of digits. With this input box, you can determine the number of digits in a group.</li>
<li><strong>Hexadecimal output</strong>: If this checkbox is set, the numbers are shown in hexadecimal format instead of decimal, which is the common notation.
To enter numbers in hexadecimal format, you will need to precede them by the string 0x. For instance, 0x38 = 56. The program shows hexadecimal numbers with monospaced font.</li>
<li><strong>Keyboard</strong>: This enables the user to select between numeric or complete (alphanumeric) virtual keyboard. The virtual keyboard appears on the screen when the user selects an input box on touch screens.
</ul>
<p>The configuration is saved in your device, so when you start again the calculator, all settings remain the same.</p>
<h2>Algorithms used</h2>
<p>The calculation of the coefficients of the continued fraction of a rational number is done as follows:</p>
<ol>
<li>Obtain the first coefficient as the integer part of the quotient between the numerator and the denominator rounded down.</li>
<li>Subtract the numerator from the product of the denominator and the newly found coefficient.</li>
<li>While the numerator is not zero:
<ol>
<li>Exchange the numerator and the denominator.</li>
<li>Obtain the following coefficient as the integer part of the quotient between the numerator and the denominator rounded down.</li>
<li>Subtract the numerator from the product of the denominator and the newly found coefficient.</li>
</ol></li></ol>
<p>The PQa algorithm is used to calculate the coefficients in the case of quadratic irrationalities, which are quotients between numerator + <span class="sqrtout"><span class="sqrtin">delta</span></span> and denominator.</p>
<ol>
<li>Repeat indefinitely:
<ol>
<li>Get the coefficient as the integer part of the quotient between numerator + <span class="sqrtout"><span class="sqrtin">delta</span></span> and the denominator rounded down.</li>
<li>Subtract the numerator from the product of the newly found coefficient and the denominator.</li>
<li>Change sign to the numerator.</li>
<li>Calculate an auxiliary result as the difference between delta and the square of the numerator.</li>
<li>Replace the denominator by the quotient between the previous auxiliary result and the denominator.</li>
</ol></li></ol>
<p>Based on the coefficients, the convergent numerators <var>A</var><sub><var>i</var></sub> and denominators <var>B</var><sub><var>i</var></sub> can be calculated using the following operations:</p>
<ol>
<li>Initialize the current and previous convergent numerator with the values 1 and 0 respectively. </li>
<li>Initialize the current and previous convergent denominator with the values 0 and 1 respectively. </li>
<li>For each coefficient obtained:
<ol>
<li>Calculate an auxiliary result as the product of the coefficient by the current convergent numerator.</li>
<li>Obtain the next convergent numerator as the sum of the auxiliary result and the previous convergent numerator.</li>
<li>Show the newly found value.</li>
<li>Replace the previous convergent numerator with the current one.</li>
<li>Replace the current convergent numerator with the next one.</li>
<li>Perform the previous five steps replacing numerator by denominator.</li>
</ol></li></ol>
<div class="noand">
<h2>Source code</h2>
<p>You can download the source of the current program and the old continued fraction applet from <a href="https://github.com/alpertron/calculators">GitHub</a>. Notice that the source code is in C language and you need the <a href="https://emscripten.org/docs/getting_started/downloads.html">Emscripten</a> environment in order to generate JavaScript.</p>
</div>
<p>Written by Dario Alpern. Last updated 10 November 2024.</p>
</div>
<div id="helphelp"></div>
<div id="result" aria-live="polite"></div>
<div id="status"></div>
<div id="cont" class="pad">
<input type="button" id="continue" value="Continue" title="Show more results. Pressing this button will delete old results.">
</div>
<div id="footer">
<p><span class="new">New!</span> You can download an application for Android that includes this calculator from <a href="https://play.google.com/store/apps/details?id=ar.com.alpertron.calculators">Google Play</a>.</p>
<p>If you find any error or you have a comment, please fill in the <a href="#" id="formlink">form</a>.</p>
<p>If you like these calculators and you want to support free software with no annoying advertisements, you can <a href="https://www.PayPal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MR65QPWZM5JT6&source=url">donate through PayPal</a>.</p>
</div>
</article>
</main>
<div id="modal-config" class="modal" role="dialog" aria-labelledby="conf">
<div class="modal-content">
<div class="modal-header"><span id="close-config" aria-label="close" class="atright">×</span><p id="conf">Configuration</p></div>
<div class="modal-body">
<div class="applet">
<fieldset>
<legend>Configuration parameters</legend>
<p><label for="digits">Digits per group</label> <input type="number" id="digits" value="6" min="0" max="10000" step="1"></p>
<p><label for="kbd">Keyboard: </label><select id="kbd"><option value="numeric">Numeric</option><option value="comp">Complete</option></select>
<p><input type="checkbox" id="hex"><label for="hex">Hexadecimal output</label></p>
</fieldset>
<p><input type="button" id="save-config" value="Save" title="Save configuration"><input type="button" id="cancel-config" value="Cancel" title="Discard changes to configuration"></p>
</div>
</div></div></div>
<aside id="feedback" aria-label="Feedback">
<h2 class="h2title">Feedback form</h2>
<form class="applet" id="formfeedback">
<input type="hidden" name="subject" value="Continued fraction calculator feedback">
<div id="formleft">
<div class="labels"><label for="name">Your name is:</label><input class="inputfbck" type="text" name="name" maxlength="40" id="name" autocomplete="name"></div>
<div class="labels"><label for="age">Age:</label><input class="inputfbck" type="number" name="age" min="0" max="999" id="age"></div>
<div class="labels"><label for="city">City:</label><input class="inputfbck" type="text" name="city" maxlength="70" id="city" autocomplete="address-level2"></div>
<div class="labels"><label for="province">Province/State:</label><input class="inputfbck" type="text" name="province" maxlength="70" id="province" autocomplete="address-level1"></div>
<div class="labels"><label for="country">Country:</label><input class="inputfbck" type="text" name="country" maxlength="70" id="country" autocomplete="country-name"></div>
<div class="labels"><label for="reply">E-mail address:</label><input class="inputfbck" type="email" name="reply" maxlength="70" id="reply" autocomplete="email"></div>
<p>All fields are optional. Enter your e-mail address if you want a reply from the author of this application.</p>
<p><input type="checkbox" id="adduserdata"><label for="adduserdata">Send input data</label></p>
<input type="hidden" name="userdata" value="" id="userdata">
</div>
<div id="formright">
<label for="comments">Please feel free to add comments:</label><br>
<textarea name="Comments" rows="7" cols="40" id="comments"></textarea>
<p><label for="how">How did you find my page?</label><br>
<select name="how" title="How did you find my page?" id="how">
<optgroup label="Select response">
<option value="from a search engine" selected>From a search engine</option>
<option value="from a friend">From a friend</option>
<option value="from a link">From a link</option>
<option value="from Wikipedia">From Wikipedia or another reference</option>
<option value="other">Other</option>
</optgroup>
</select></p>
<fieldset><legend>Are the programs instructive?</legend>
<input type="radio" name="Instructive" value="Yes" id="insyes"><label for="insyes">Yes</label>
<input type="radio" name="Instructive" value="No" id="insno"><label for="insno">No</label>
</fieldset>
<fieldset><legend>Are the programs interesting?</legend>
<input type="radio" name="Interesting" value="Yes" id="intyes"><label for="intyes">Yes</label>
<input type="radio" name="Interesting" value="No" id="intno"><label for="intno">No</label>
</fieldset>
<p><button type="submit" disabled="disabled" id="formsend" title="Deliver this form">Send it in!</button>
<button type="reset">Reset</button>
<button type="button" id="formcancel" title="Do not deliver this form">Cancel</button></p>
</div>
<div class="lf"></div>
</form>
</aside>
<aside id="sending">
<p>Sending comments...</p>
</aside>
<aside id="sentOK">
<p>Feedback sent successfully.</p>
<div class="center"><button type="button" id="btnSentOK">Go back</button></div>
</aside>
<aside id="notSent">
<p>Feedback could not be sent.</p>
<div class="center"><button type="button" id="btnNotSent">Go back</button></div>
</aside>
<script type="text/wasmb64" id="wasmb64">
</script>
<script>
<!--
//-->
</script>
<script type="text/js-worker" id="worker">
var e,g,k,l={env:{databack:function(b){var a=-1,c=0,f="",d="";do{for(c=0;1024>c;c++){a=g[b++>>0];if(0==a)break;128<=a&&(a=(a-192<<6)+g[b++>>0]-128);f+=String.fromCharCode(a)}d+=f;f=""}while(0!=a);self.postMessage(d+f)},tenths:function(){return Math.floor((new Date).getTime()/100)}}};
self.onmessage=function(b){k?(m(e.getInputStringPtr(),b.data[0]),e.doWork()):WebAssembly.instantiate(b.data[1],l).then(function(a){k=1;e=a.instance.exports;g=new Uint8Array(e.memory.buffer);m(e.getInputStringPtr(),b.data[0]);e.doWork()})};function m(b,a){var c=b,f=a.length,d,h;for(d=0;d<f;d++)h=a.charCodeAt(d),128>h?g[c++]=h:(g[c++]=(h>>6)+192,g[c++]=(h&63)+128);g[c]=0};
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"browserRequirements": "Requires HTML5. Requires Javascript.",
"name": "Continued Fraction calculator",
"description": "Web application that finds the continued fraction representation of rational numbers and quadratic irrationalities.",
"image": ["https://www.alpertron.com.ar/contfrac.png"],
"datePublished": "2024-11-04",
"dateModified": "2024-11-04",
"operatingSystem": "Any",
"applicationCategory": "EducationalApplication",
"author": {
"@type": "Person",
"name": "Dario Alpern"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.1",
"ratingCount": "36"
},
"inLanguage": "en",
"license": "https://www.gnu.org/licenses/gpl-3.0.en.html",
"isAccessibleForFree": true,
"offers": {
"@type": "Offer",
"availability": "https://schema.org/OnlineOnly",
"price": "0",
"priceCurrency": "USD"
}
}
</script>
</body>
</html>