a-conjecture-of-mine

An exercise on polyglossy: the same problem solved on multiple languages

commit fa97703c1cdc4ffe9f8128e814b09fd8f57fd27a
parent ea51224d227b1056ee562dba10f035f2a2729fa4
Author: Gark Garcia <37553739+GarkGarcia@users.noreply.github.com>
Date:   Fri,  8 Mar 2019 19:53:30 -0300

Optimized the rust and haskell implementations.

Diffstat:
M.gitignore | 4++++
MHaskell/app/Main.hs | 39++++++++++++++++-----------------------
MHaskell/conjecture.cabal | 4++--
MHaskell/package.yaml | 1+
DLatex/digital_sum.aux | 1-
DLatex/digital_sum.log | 384-------------------------------------------------------------------------------
DLatex/digital_sum.pdf | 0
DLatex/digital_sum.synctex.gz | 0
DLatex/digital_sum.tex | 43-------------------------------------------
MREADME.md | 9++++-----
MRust/src/main.rs | 96++++++++++++++++++++++++++++++++++++++++----------------------------------------
DTypeScript/script.js | 109-------------------------------------------------------------------------------
DTypeScript/script.min.js | 2--
DTypeScript/script.ts | 141-------------------------------------------------------------------------------
Mscript.js | 15+++------------
Mscript.py | 39+++++++++++++--------------------------
Mscript.ts | 103++++++++++++++++---------------------------------------------------------------
Mscript.ts.js | 7+++++--
18 files changed, 116 insertions(+), 881 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+*.exe
+Statistics
+Latex+
\ No newline at end of file
diff --git a/Haskell/app/Main.hs b/Haskell/app/Main.hs
@@ -3,44 +3,37 @@ module Main where
 import Numeric
 import Numeric.Natural
 import System.Clock
+import GHC.Conc
 
 main :: IO ()
 main = do
+    -- Configure the number of threads used by the program
+    setNumCapabilities 1
+
     putStrLn "\nThis program is a simple test for the following conjecture:\n"
     putStrLn "Let S: N -> N be the sum of the digits of a positive integer."
     putStrLn "For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"
     putStrLn "What value would you like to test the conjecture for?"
-
     maxStr <- getLine
-    let max = readDec maxStr
 
-    if (not $ null max) && ((snd $ head max ) == "")
-        then let counter = exceptions' 0 (fst $ head max) in do
+    case readDec maxStr :: [(Natural, String)] of
+        [(max, "")] -> do
             start <- getTime Monotonic
             putStrLn "\nLOADING. . ."
 
-            if null counter
-                then do 
+            case exceptions' 0 max of
+                [] -> do 
                     end <- getTime Monotonic
-                    putStrLn $ "LOADED in " ++ formatTime (end - start) ++ "s [1 Thread]"
-                    putStrLn $ "\nThe conjecture is proved for all natural numbers smaller or equals to " ++ show (fst $ head max) ++ "!"
-                    exit
-                else do
-                    putStrLn $ "\nThe conjecture is disproved! Here are the counter examples:\n" ++ (init $ tail $ show counter)
-                    exit
-        else do
-            putStrLn $ "\n'" ++ maxStr ++ "' is not a natural number!"
-            exit
-
-exit :: IO ()
-exit = do
-    putStrLn "Press any key to continue. . ."
-    getChar
-    return ()
+                    putStrLn $ "LOADED. . . in " ++ formatTime (end - start) ++ "s [1 Thread]"
+                    putStrLn $ "\nThe conjecture is proved for all natural numbers smaller or equals to " ++ show max ++ "!"
+                counter -> putStrLn $ "\nThe conjecture is disproved! Here are the counter examples:\n" ++ (init $ tail $ show counter)
+                
+        _ -> putStrLn $ "\n'" ++ maxStr ++ "' is not a natural number!"
 
 digs :: Natural -> [Natural]
-digs 0 = [0]
-digs x = digs (x `div` 10) ++ [x `mod` 10]
+digs x = case x of
+    0 -> [0]
+    x -> digs (x `div` 10) ++ [x `mod` 10]
 
 sum' :: Natural -> Natural
 sum' x = sum $ digs x
diff --git a/Haskell/conjecture.cabal b/Haskell/conjecture.cabal
@@ -4,7 +4,7 @@ cabal-version: 1.12
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 3cf9a6d881ec7aedbc39501d43197ec9a1e4562b5d73a7f1f14420405cc67697
+-- hash: 8aa8667b3d4cd7fa12aca4ea4b2ddbfe34b6f53704ead53843307c5cd05e1045
 
 name:           conjecture
 version:        1.0.0.0
@@ -34,7 +34,7 @@ executable conjecture-exe
       Paths_conjecture
   hs-source-dirs:
       app
-  ghc-options: -threaded -rtsopts -with-rtsopts=-N
+  ghc-options: -threaded -rtsopts -with-rtsopts=-N -O
   build-depends:
       base >=4.7 && <5
     , clock ==0.7.2
diff --git a/Haskell/package.yaml b/Haskell/package.yaml
@@ -31,6 +31,7 @@ executables:
       - -threaded
       - -rtsopts
       - -with-rtsopts=-N
+      - -O
     dependencies:
       - conjecture
       - clock == 0.7.2
diff --git a/Latex/digital_sum.aux b/Latex/digital_sum.aux
@@ -1 +0,0 @@
-\relax 
diff --git a/Latex/digital_sum.log b/Latex/digital_sum.log
@@ -1,384 +0,0 @@
-This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6745 64-bit) (preloaded format=pdflatex 2018.8.8)  27 FEB 2019 11:08
-entering extended mode
-**./digital_sum.tex
-(digital_sum.tex
-LaTeX2e <2018-04-01> patch level 5
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\article.cls"
-Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\size10.clo"
-File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
-)
-\c@part=\count80
-\c@section=\count81
-\c@subsection=\count82
-\c@subsubsection=\count83
-\c@paragraph=\count84
-\c@subparagraph=\count85
-\c@figure=\count86
-\c@table=\count87
-\abovecaptionskip=\skip41
-\belowcaptionskip=\skip42
-\bibindent=\dimen102
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\blindtext\blindtex
-t.sty"
-Package: blindtext 2012/01/06 V2.0 blindtext-Package
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\xspace.sty"
-Package: xspace 2014/10/28 v1.13 Space after command names (DPC,MH)
-)
-\c@blindtext=\count88
-\c@Blindtext=\count89
-\c@blind@countparstart=\count90
-\blind@countxx=\count91
-\blindtext@numBlindtext=\count92
-\blind@countyy=\count93
-\c@blindlist=\count94
-\c@blindlistlevel=\count95
-\c@blindlist@level=\count96
-\blind@listitem=\count97
-\c@blind@listcount=\count98
-\c@blind@levelcount=\count99
-\blind@mathformula=\count100
-\blind@Mathformula=\count101
-\c@blind@randomcount=\count102
-\c@blind@randommax=\count103
-\c@blind@pangramcount=\count104
-\c@blind@pangrammax=\count105
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.
-sty"
-Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
-\@emptytoks=\toks14
-\symAMSa=\mathgroup4
-\symAMSb=\mathgroup5
-LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
-(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\mathtools\mathtool
-s.sty"
-Package: mathtools 2018/01/08 v1.21 mathematical typesetting tools
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\keyval.st
-y"
-Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
-\KV@toks@=\toks15
-) ("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\tools\calc.sty"
-Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
-\calc@Acount=\count106
-\calc@Bcount=\count107
-\calc@Adimen=\dimen103
-\calc@Bdimen=\dimen104
-\calc@Askip=\skip43
-\calc@Bskip=\skip44
-LaTeX Info: Redefining \setlength on input line 80.
-LaTeX Info: Redefining \addtolength on input line 81.
-\calc@Ccount=\count108
-\calc@Cskip=\skip45
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\mathtools\mhsetup.
-sty"
-Package: mhsetup 2017/03/31 v1.3 programming setup (MH)
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsmath.st
-y"
-Package: amsmath 2017/09/02 v2.17a AMS math features
-\@mathmargin=\skip46
-
-For additional information on amsmath, use the `?' option.
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amstext.st
-y"
-Package: amstext 2000/06/29 v2.01 AMS text
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty
-"
-File: amsgen.sty 1999/11/30 v2.0 generic functions
-\@emptytoks=\toks16
-\ex@=\dimen105
-))
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty
-"
-Package: amsbsy 1999/11/29 v1.2d Bold Symbols
-\pmbraise@=\dimen106
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsmath\amsopn.sty
-"
-Package: amsopn 2016/03/08 v2.02 operator names
-)
-\inf@bad=\count109
-LaTeX Info: Redefining \frac on input line 213.
-\uproot@=\count110
-\leftroot@=\count111
-LaTeX Info: Redefining \overline on input line 375.
-\classnum@=\count112
-\DOTSCASE@=\count113
-LaTeX Info: Redefining \ldots on input line 472.
-LaTeX Info: Redefining \dots on input line 475.
-LaTeX Info: Redefining \cdots on input line 596.
-\Mathstrutbox@=\box26
-\strutbox@=\box27
-\big@size=\dimen107
-LaTeX Font Info:    Redeclaring font encoding OML on input line 712.
-LaTeX Font Info:    Redeclaring font encoding OMS on input line 713.
-\macc@depth=\count114
-\c@MaxMatrixCols=\count115
-\dotsspace@=\muskip10
-\c@parentequation=\count116
-\dspbrk@lvl=\count117
-\tag@help=\toks17
-\row@=\count118
-\column@=\count119
-\maxfields@=\count120
-\andhelp@=\toks18
-\eqnshift@=\dimen108
-\alignsep@=\dimen109
-\tagshift@=\dimen110
-\tagwidth@=\dimen111
-\totwidth@=\dimen112
-\lineht@=\dimen113
-\@envbody=\toks19
-\multlinegap=\skip47
-\multlinetaggap=\skip48
-\mathdisplay@stack=\toks20
-LaTeX Info: Redefining \[ on input line 2817.
-LaTeX Info: Redefining \] on input line 2818.
-)
-LaTeX Info: Thecontrolsequence`\('isalreadyrobust on input line 129.
-LaTeX Info: Thecontrolsequence`\)'isalreadyrobust on input line 129.
-LaTeX Info: Thecontrolsequence`\['isalreadyrobust on input line 129.
-LaTeX Info: Thecontrolsequence`\]'isalreadyrobust on input line 129.
-\g_MT_multlinerow_int=\count121
-\l_MT_multwidth_dim=\dimen114
-\origjot=\skip49
-\l_MT_shortvdotswithinadjustabove_dim=\dimen115
-\l_MT_shortvdotswithinadjustbelow_dim=\dimen116
-\l_MT_above_intertext_sep=\dimen117
-\l_MT_below_intertext_sep=\dimen118
-\l_MT_above_shortintertext_sep=\dimen119
-\l_MT_below_shortintertext_sep=\dimen120
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\geometry.
-sty"
-Package: geometry 2018/04/16 v5.8 Page Geometry
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.s
-ty"
-Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.
-sty"
-Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
-Package ifvtex Info: VTeX not detected.
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.
-sty"
-Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
-)
-\Gm@cnth=\count122
-\Gm@cntv=\count123
-\c@Gm@tempcnt=\count124
-\Gm@bindingoffset=\dimen121
-\Gm@wd@mp=\dimen122
-\Gm@odd@mp=\dimen123
-\Gm@even@mp=\dimen124
-\Gm@layoutwidth=\dimen125
-\Gm@layoutheight=\dimen126
-\Gm@layouthoffset=\dimen127
-\Gm@layoutvoffset=\dimen128
-\Gm@dimlist=\toks21
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\geometry\geometry.
-cfg"))
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\base\inputenc.sty"
-Package: inputenc 2018/04/06 v1.3b Input encoding file
-\inpenc@prehook=\toks22
-\inpenc@posthook=\toks23
-) (digital_sum.aux)
-\openout1 = `digital_sum.aux'.
-
-LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 11.
-LaTeX Font Info:    ... okay on input line 11.
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\graphicx.
-sty"
-Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\graphics.
-sty"
-Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics\trig.sty"
-Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-cfg\graph
-ics.cfg"
-File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
-)
-Package graphics Info: Driver file: pdftex.def on input line 99.
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\graphics-def\pdfte
-x.def"
-File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\context\base\supp-pdf.mk
-ii"
-[Loading MPS to PDF converter (version 2006.09.02).]
-\scratchcounter=\count125
-\scratchdimen=\dimen129
-\scratchbox=\box28
-\nofMPsegments=\count126
-\nofMParguments=\count127
-\everyMPshowfont=\toks24
-\MPscratchCnt=\count128
-\MPscratchDim=\dimen130
-\MPnumerator=\count129
-\makeMPintoPDFobject=\count130
-\everyMPtoPDFconversion=\toks25
-)))
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-
-base.sty"
-Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\infware
-rr.sty"
-Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
-)
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\grfext.st
-y"
-Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\kvdefin
-ekeys.sty"
-Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds
-.sty"
-Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
-)))
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\oberdiek\kvoptions
-.sty"
-Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\kvsetke
-ys.sty"
-Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\etexcmd
-s.sty"
-Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
-
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\ifluate
-x.sty"
-Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
-Package ifluatex Info: LuaTeX not detected.
-)
-Package etexcmds Info: Could not find \expanded.
-(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
-(etexcmds)             that some package has redefined \expanded.
-(etexcmds)             In the latter case, load this package earlier.
-)))
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\pdftexc
-mds.sty"
-Package: pdftexcmds 2018/01/30 v0.27 Utility functions of pdfTeX for LuaTeX (HO
-)
-Package pdftexcmds Info: LuaTeX not detected.
-Package pdftexcmds Info: \pdf@primitive is available.
-Package pdftexcmds Info: \pdf@ifprimitive is available.
-Package pdftexcmds Info: \pdfdraftmode found.
-)
-Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
-38.
-Package grfext Info: Graphics extension search list:
-(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
-G,.JBIG2,.JB2,.eps]
-(grfext)             \AppendGraphicsExtensions on input line 456.
-)
-\Gin@req@height=\dimen131
-\Gin@req@width=\dimen132
-)
-*geometry* driver: auto-detecting
-*geometry* detected driver: pdftex
-*geometry* verbose mode - [ preamble ] result:
-* driver: pdftex
-* paper: a4paper
-* layout: <same size as paper>
-* layoutoffset:(h,v)=(0.0pt,0.0pt)
-* modes: 
-* h-part:(L,W,R)=(81.94394pt, 433.62pt, 81.94394pt)
-* v-part:(T,H,B)=(77.84674pt, 650.43pt, 116.77011pt)
-* \paperwidth=597.50787pt
-* \paperheight=845.04684pt
-* \textwidth=433.62pt
-* \textheight=650.43pt
-* \oddsidemargin=9.67395pt
-* \evensidemargin=9.67395pt
-* \topmargin=-31.42325pt
-* \headheight=12.0pt
-* \headsep=25.0pt
-* \topskip=10.0pt
-* \footskip=30.0pt
-* \marginparwidth=65.0pt
-* \marginparsep=11.0pt
-* \columnsep=10.0pt
-* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
-* \hoffset=0.0pt
-* \voffset=0.0pt
-* \mag=1000
-* \@twocolumnfalse
-* \@twosidefalse
-* \@mparswitchfalse
-* \@reversemarginfalse
-* (1in=72.27pt=25.4mm, 1cm=28.453pt)
-
-LaTeX Font Info:    Try loading font information for U+msa on input line 12.
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd"
-File: umsa.fd 2013/01/14 v3.01 AMS symbols A
-)
-LaTeX Font Info:    Try loading font information for U+msb on input line 12.
-("C:\Users\thiag\AppData\Local\Programs\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd"
-File: umsb.fd 2013/01/14 v3.01 AMS symbols B
-) [1
-
-{C:/Users/thiag/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
-(digital_sum.aux) ) 
-Here is how much of TeX's memory you used:
- 3364 strings out of 492973
- 50647 string characters out of 3126693
- 126345 words of memory out of 3000000
- 7177 multiletter control sequences out of 15000+200000
- 11901 words of font info for 46 fonts, out of 3000000 for 9000
- 1141 hyphenation exceptions out of 8191
- 55i,7n,34p,301b,197s stack positions out of 5000i,500n,10000p,200000b,50000s
-<C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type
-1/public/amsfonts/cm/cmbx10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2
-.9/fonts/type1/public/amsfonts/cm/cmbxti10.pfb><C:/Users/thiag/AppData/Local/Pr
-ograms/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmex10.pfb><C:/Users/thiag/App
-Data/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Us
-ers/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi
-7.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsf
-onts/cm/cmr10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1
-/public/amsfonts/cm/cmr12.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9
-/fonts/type1/public/amsfonts/cm/cmr17.pfb><C:/Users/thiag/AppData/Local/Program
-s/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr7.pfb><C:/Users/thiag/AppData/Lo
-cal/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Users/thi
-ag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy7.pfb><
-C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm
-/cmti10.pfb><C:/Users/thiag/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/publi
-c/amsfonts/symbols/msbm10.pfb>
-Output written on digital_sum.pdf (1 page, 123385 bytes).
-PDF statistics:
- 58 PDF objects out of 1000 (max. 8388607)
- 0 named destinations out of 1000 (max. 500000)
- 1 words of extra memory for PDF output out of 10000 (max. 10000000)
-
diff --git a/Latex/digital_sum.pdf b/Latex/digital_sum.pdf
Binary files differ.
diff --git a/Latex/digital_sum.synctex.gz b/Latex/digital_sum.synctex.gz
Binary files differ.
diff --git a/Latex/digital_sum.tex b/Latex/digital_sum.tex
@@ -1,42 +0,0 @@
-\documentclass{article}
-\usepackage{blindtext}
-\usepackage{amsfonts}
-\usepackage{mathtools}
-\pagenumbering{gobble}
-\usepackage[a4paper, total={6in, 9in}]{geometry}
-\usepackage[utf8]{inputenc}
-\title{Conjectura Mia}
-\author{Eli \& Thiago}
-\date{29 de dezembro de 2018}
-\begin{document}
-	\maketitle
-	\section*{\textit{Conjecture:}}
-		Let $S:\mathbb{N} \rightarrow \mathbb{N}$ be the sum of digits of a number $n \in \mathbb{N}$ --- represented in a \textit{base $\delta$ posicional system} --- and let $\nu \coloneqq \delta - 1$. We have:
-		
-		$$
-		\forall a, b \in \mathbb{N} : S_{a+b}=S_a + S_b + \nu k, k \in \mathbb{Z}
-		$$
-
-	\section*{\textit{Proof:}}
-		For all $a \in \mathbb{N}$:
-		$$
-		a = a_0 \cdot 10_\delta^0 + a_1 \cdot 10_\delta^1 + \dots + a_n \cdot 10_\delta^n \Rightarrow S_a = a_0 + a_1 + \dots + a_n
-		$$
-		\noindent Therefore:
-		$$
-		\begin{matrix}
-		a = a_0 \cdot (1 + \nu)^0 + \dots + a_n (1 + \nu)^n = a_0 \cdot (1 + \nu k_0) + \dots + a_n \cdot (1 + \nu k_n) \\ = a_0 + \dots + a_n + \nu k = S_a + \nu k, k \in \mathbb{Z}
-		\end{matrix}
-		$$
-		
-		\noindent Thus, for $c \coloneqq a + b$:
-		$$
-		\begin{cases}
-		& c = S_c + \nu k, k \in \mathbb{Z} \\
-		& a + b = (S_a + \nu k) + (S_b + \nu k') = S_a + S_b + \nu k''\;|\; k, k', k''\in \mathbb{Z}
-		\end{cases}
-		$$
-		
-		Therefore $c = a + b \Rightarrow S_c + \nu k = S_a + S_b + \nu k'\;|\; k, k'\in \mathbb{Z} \Rightarrow S_c = S_{a + b} = S_a + S_b + \nu k, k \in \mathbb{Z}$
-		\noindent \textbf{Q.E.D}
-\end{document}-
\ No newline at end of file
diff --git a/README.md b/README.md
@@ -11,8 +11,8 @@ The conjecture was [proved by exhaustion](https://en.wikipedia.org/wiki/Proof_by
 |Language      |Time   |Number of Threads Used|
 |--------------|-------|----------------------|
 |**Rust**      |22 _s_ |2                     |
-|**Haskell**   |60 _s_ |1                     |
-|**TypeScript**|198 _s_|1                     |
-|**JavaScript**|202 _s_|1                     |
+|**Haskell**   |48 _s_ |1                     |
+|**JavaScript**|197 _s_|1                     |
+|**TypeScript**|219 _s_|1                     |
 |**Ruby**      |273 _s_|1                     |
-|**Python**    |400 _s_|1                     |-
\ No newline at end of file
+|**Python**    |522 _s_|1                     |
diff --git a/Rust/src/main.rs b/Rust/src/main.rs
@@ -8,7 +8,7 @@ extern crate num_cpus;
 extern crate rand;
 
 use std::{env, thread, time::Instant, sync::mpsc, sync::mpsc::{Sender, Receiver}};
-use crossterm::{terminal, input, ClearType};
+use crossterm::{terminal, input};
 use rand::prelude::*;
 
 fn main() {
@@ -18,14 +18,14 @@ fn main() {
     // Assign the correct number of threads to run the application with
     // The default is the number of cores in the machine
     let n_cores = num_cpus::get_physical();
-    let n_threads = if args.len() == 0 { n_cores } else {
-        match args[0].trim().parse::<usize>() {
+    let n_threads = if args.len() <= 1 { n_cores } else {
+        match args[1].trim().parse::<usize>() {
             Ok(n_arg) => std::cmp::min(n_arg, n_cores),
             Err(_) => n_cores
         }
     };
 
-    println!("This program is a simple test for the following conjecture:\n");
+    println!("\nThis program is a simple test for the following conjecture:\n");
     println!("Let S: N -> N be the sum of the digits of a positive integer.");
     println!("For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an integer.");
 
@@ -41,61 +41,67 @@ fn main() {
             let duration = start_time.elapsed();
 
             // Print the results
-            if let Err(err) = prompt.clear(ClearType::All) { panic!(err); }
-            println!("LOADED. . . 100% in {}s [{} threads]\n", duration.as_secs(), n_threads);
+            println!("LOADED. . . in {}s [{} Threads]\n", duration.as_secs(), n_threads);
             if counterexpls.len() == 0 {
                 println!("The conjecture is proved for all natural numbers smaller or equals to {}!", max);
             } else {
                 println!("The conjecture is disproved! Here are the counter examples:");
 
-                let mut counterexpls_str = String::new();
-
-                for pair in counterexpls {
-                    let ordered_pair = format!("({}, {})", pair[0], pair[1]);
-                    counterexpls_str = format!("{}, {}", counterexpls_str, ordered_pair);
-                }
-
-                println!("{}\n", counterexpls_str);
+                let counterexpls_str: Vec<String> = counterexpls.iter().map(|(a, b)| format!("({}, {})", a, b)).collect();
+                println!("{}\n", counterexpls_str.join(","));
             }
-
-            if let Err(err) = prompt.write("Press any key to continue. . . ") { panic!(err); }
-            let _ = input().read_char();
         }, 
         Err(_) => println!("'{}' is not a natural number!", user_input.trim())
     }
 }
 
-fn get_all_countrexpls(max: usize, n_threads: usize) -> Vec<[usize; 2]> {
+fn get_all_countrexpls(max: usize, n_threads: usize) -> Vec<(usize, usize)> {
     if max / n_threads > 0 && n_threads > 1 {
 
         // Thread related variables
-        let (coutexpl_sender, coutexpl_reciever): (Sender<Vec<[usize; 2]>>, Receiver<Vec<[usize; 2]>>) = mpsc::channel();
+        let (coutexpl_sender, coutexpl_reciever): (Sender<Vec<(usize, usize)>>, Receiver<Vec<(usize, usize)>>) = mpsc::channel();
         let mut child_threads = Vec::new();
         let range_lenght = max / n_threads;
         let mut range: Vec<usize> = (0..max).collect();
 
         // Conjecture related variables
-        let mut counterexpls: Vec<[usize; 2]> = Vec::new();
+        let mut counterexpls: Vec<(usize, usize)> = Vec::new();
 
-        // Shuffle the values in the range to get an even distribution of calculations across all threads
+        // Shuffle the values in the range to get an even distribution of
+        // calculations across all threads
         range.shuffle(&mut thread_rng());
 
-        for i in 1..n_threads {
-            let thread_countr_sd = coutexpl_sender.clone();
+        // Separate a specific slice of the range and assign it to the thread
+        let mut sub_ranges = Vec::new();
+        for i in 0..n_threads {
+            let start = i * range_lenght;
+            let end = start + range_lenght;
+            sub_ranges.push(range[(start as usize)..(end as usize)].to_vec());
+        }
 
-            // Separate a specific slice of the range and assign it to the thread
-            let start = (i - 1) * range_lenght;
-            let end = start + range_lenght - 1;
-            let thread_range = range[(start as usize)..(end as usize)].to_vec();
+        // Account for the fact that the maximum number tested may not be
+        // a multiple of the numbers of threads used for computations, hence
+        // the number of test performed by each thread may not be constant
+        if max % n_threads != 0 {
+            let mut rng = thread_rng();
+            let end = sub_ranges.len() - 1;
+            let mut remainders = range[(max - max % n_threads)..max].to_vec();
+
+            while let Some(val) = remainders.pop() {
+                sub_ranges[rng.gen_range(0, end)].push(val);
+            }
+        }
+
+        for i in 0..n_threads {
+            let thread_countr_sd = coutexpl_sender.clone();
+            let thread_range = sub_ranges.pop().unwrap();
 
             let child = thread::spawn(move || {
                 thread_countr_sd.send(get_range_countrexpls(thread_range, max))
                     .expect(&format!("Thread n°{} was unable to sent a message trought the channel", i));
             });
+            
             child_threads.push(child);
-        }
-
-        for _ in 1..n_threads {
             counterexpls.append(&mut coutexpl_reciever.recv().unwrap());
         }
 
@@ -109,15 +115,15 @@ fn get_all_countrexpls(max: usize, n_threads: usize) -> Vec<[usize; 2]> {
     }
 }
 
-fn get_range_countrexpls(range: Vec<usize>, max: usize) -> Vec<[usize; 2]> {
+fn get_range_countrexpls(range: Vec<usize>, max: usize) -> Vec<(usize, usize)> {
     let mut counterexpls = Vec::new();
 
     for a in range {
         for b in a..max {
             let difference = sum_digits(a + b) - sum_digits(a) - sum_digits(b);
 
-            if !is_multiple_of_nine(difference) {
-                counterexpls.push([a, b]);
+            if difference % 9 != 0 {
+                counterexpls.push((a, b));
             }
         }
     }
@@ -125,23 +131,17 @@ fn get_range_countrexpls(range: Vec<usize>, max: usize) -> Vec<[usize; 2]> {
     counterexpls
 }
 
-fn is_multiple_of_nine(n: isize) -> bool {
-    let floor = n / 9;
-    let neerest_mult = floor * 9;
-
-    n == neerest_mult
-}
+fn get_digits(n: usize) -> Vec<usize> {
+    if n == 0 {
+        vec![0]
+    } else {
+        let mut digs = vec![n % 10];
+        digs.append(&mut get_digits(n / 10));
 
-fn get_digits(n: usize) -> Vec<u32> {
-    n.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect()
+        digs
+    }
 }
 
 fn sum_digits(n: usize) -> isize {
-    let mut sum = 0;
-
-    for d in get_digits(n) {
-        sum += d as isize;
-    }
-
-    sum
+    get_digits(n).iter().sum::<usize>() as isize
 } 
\ No newline at end of file
diff --git a/TypeScript/script.js b/TypeScript/script.js
@@ -1,109 +0,0 @@
-// The following script is a simple test for the following conjecture:
-// Let S: N -> N be the sum of the digits of a positive integer.
-// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
-const readline = require('readline');
-class Int {
-    constructor(n) {
-        this.val = n;
-    }
-    add(n) {
-        return new Int(this.val + n.val);
-    }
-    subtrack(n) {
-        return new Int(this.val - n.val);
-    }
-    multiply(n) {
-        return new Int(this.val * n.val);
-    }
-    divide(n) {
-        return new Int(Math.floor(this.val / n.val));
-    }
-    incrementBy(n) {
-        this.val += n.val;
-    }
-    divides(n) {
-        return (n.val / this.val) % 1 == 0;
-    }
-    getDigits() {
-        return Array.from(this.val.toString()).map(char => Int.from(char));
-    }
-    sumDigits() {
-        let sum = Int.zero();
-        const digits = this.getDigits();
-        for (const n of digits)
-            sum.incrementBy(n);
-        return sum;
-    }
-    toString() {
-        return `${this.val}`;
-    }
-    static from(a) {
-        return new Int(Math.round(Number(a)));
-    }
-    static getRange(a, b) {
-        const start = a.val, end = b.val, range = [];
-        for (let i = start; i < end; i++) {
-            range.push(Int.from(i));
-        }
-        return range;
-    }
-    static zero() {
-        return new Int(0);
-    }
-    static one() {
-        return new Int(1);
-    }
-}
-function askQuestion(query) {
-    const rl = readline.createInterface({
-        input: process.stdin,
-        output: process.stdout,
-    });
-    return new Promise((resolve) => rl.question(query, (ans) => {
-        rl.close();
-        resolve(ans);
-    }));
-}
-function getCounterExp(max) {
-    const starTime = new Date(), counterexmpls = [], nine = Int.from(9);
-    let loadBar = Int.zero();
-    for (const a of Int.getRange(Int.one(), max)) {
-        const newLoadBar = a.multiply(Int.from(100)).divide(max);
-        if (loadBar != newLoadBar) {
-            console.clear();
-            loadBar = newLoadBar;
-            console.log(`LOADING. . . ${loadBar}%`);
-        }
-        for (const b of Int.getRange(a, max)) {
-            // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9
-            const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits())));
-            if (!conjectureHolds)
-                counterexmpls.push([a, b]);
-        }
-    }
-    const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000;
-    console.clear();
-    console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`);
-    return counterexmpls;
-}
-console.log(`This script is a simple test for the following conjecture:
-    
-Let S: N -> N be the sum of the digits of a positive integer.
-For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
-`);
-askQuestion("What value would you like to test the conjecture for? ").then(ans => {
-    if (!isNaN(Number(ans))) {
-        const max = Int.from(ans), counterexmpls = getCounterExp(max);
-        if (counterexmpls.length == 0)
-            console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`);
-        else {
-            console.log("The conjecture is disproved! Here are the counter examples:");
-            let counterexmplsStr = "";
-            for (const pair of counterexmpls)
-                counterexmplsStr = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`;
-            console.log(counterexmplsStr);
-        }
-    }
-    else
-        console.log(`'${ans}' is not an interger!`);
-}).catch(console.error);
diff --git a/TypeScript/script.min.js b/TypeScript/script.min.js
@@ -1 +0,0 @@
-const e=require("readline");class t{constructor(e){this.val=e}add(e){return new t(this.val+e.val)}subtrack(e){return new t(this.val-e.val)}multiply(e){return new t(this.val*e.val)}divide(e){return new t(Math.floor(this.val/e.val))}incrementBy(e){this.val+=e.val}divides(e){return e.val/this.val%1==0}getDigits(){return Array.from(this.val.toString()).map(e=>t.from(e))}sumDigits(){let e=t.zero();const o=this.getDigits();for(const t of o)e.incrementBy(t);return e}toString(){return`${this.val}`}static from(e){return new t(Math.round(Number(e)))}static getRange(e,o){const r=e.val,n=o.val,s=[];for(let e=r;e<n;e++)s.push(t.from(e));return s}static zero(){return new t(0)}static one(){return new t(1)}}console.log("This script is a simple test for the following conjecture:\n    \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(t){const o=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>o.question(t,t=>{o.close(),e(t)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(Number(e)))console.log(`'${e}' is not an interger!`);else{const o=t.from(e),r=function(e){const o=new Date,r=[],n=t.from(9);let s=t.zero();for(const o of t.getRange(t.one(),e)){const i=o.multiply(t.from(100)).divide(e);s!=i&&(console.clear(),s=i,console.log(`LOADING. . . ${s}%`));for(const s of t.getRange(o,e))n.divides(o.add(s).sumDigits().subtrack(o.sumDigits().add(s.sumDigits())))||r.push([o,s])}const i=((new Date).getTime()-o.getTime())/1e3;return console.clear(),console.log(`LOADED. . . ${s}% in ${i}s\n`),r}(o);if(0==r.length)console.log(`The conjecture is proved for all natural numbers smaller or equals to ${o}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(const t of r)e=`${e}, (${t[0]}, ${t[1]})`;console.log(e)}}}).catch(console.error);-
\ No newline at end of file
diff --git a/TypeScript/script.ts b/TypeScript/script.ts
@@ -1,140 +0,0 @@
-// The following script is a simple test for the following conjecture:
-
-// Let S: N -> N be the sum of the digits of a positive integer.
-// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
-
-const readline = require('readline');
-
-class Int {
-    private val: number;
-
-    private constructor(n: number) {
-        this.val = n;
-    }
-
-    public add(n: Int): Int {
-        return new Int(this.val + n.val);
-    }
-
-    public subtrack(n: Int): Int {
-        return new Int(this.val - n.val);
-    }
-
-    public multiply(n: Int): Int {
-        return new Int(this.val * n.val);
-    }
-
-    public divide(n: Int): Int {
-        return new Int(Math.floor(this.val / n.val));
-    }
-
-    public incrementBy(n: Int) {
-        this.val += n.val;
-    }
-
-    public divides(n: Int): boolean {
-        return (n.val / this.val) % 1 == 0;
-    }
-
-    public getDigits(): Int[] {
-        return Array.from(this.val.toString()).map(char => Int.from(char));
-    }
-
-    public sumDigits(): Int {
-        let sum = Int.zero();
-        const digits = this.getDigits();
-
-        for (const n of digits)
-            sum.incrementBy(n);
-
-        return sum;
-    }
-
-    public toString(): string {
-        return `${this.val}`;
-    }
-
-    static from(a: number | string): Int {
-        return new Int(Math.round(Number(a)));
-    }
-
-    static getRange(a: Int, b: Int): Int[] {
-        const start = a.val, end = b.val, range: Int[] = [];
-
-        for (let i = start; i < end; i++) {
-            range.push(Int.from(i));
-        }
-
-        return range;
-    }
-
-    static zero(): Int {
-        return new Int(0);
-    }
-
-    static one(): Int {
-        return new Int(1);
-    }
-}
-
-function askQuestion(query: string): Promise<string> {
-    const rl = readline.createInterface({
-        input: process.stdin,
-        output: process.stdout,
-    });
-
-    return new Promise(resolve => rl.question(query, (ans: string) => {
-        rl.close();
-        resolve(ans);
-    }));
-}
-
-function getCounterExp(max: Int) {
-    const starTime = new Date(), counterexmpls: [Int, Int][] = [], nine = Int.from(9);
-    let loadBar = Int.zero();
-
-    for (const a of Int.getRange(Int.one(), max)) {
-
-        const newLoadBar = a.multiply(Int.from(100)).divide(max);
-        if (loadBar != newLoadBar) {
-            console.clear();
-            loadBar = newLoadBar;
-            console.log(`LOADING. . . ${loadBar}%`);
-        }
-
-        for (const b of Int.getRange(a, max)) {
-            // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9
-            const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits())));
-            if (!conjectureHolds) counterexmpls.push([a, b]);
-        }
-    }
-
-    const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000;
-    console.clear();
-    console.log(`LOADED. . . ${loadBar}% in ${elepsedTime}s\n`);
-    return counterexmpls;
-}
-
-console.log(`This script is a simple test for the following conjecture:
-    
-Let S: N -> N be the sum of the digits of a positive integer.
-For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
-`);
-
-askQuestion("What value would you like to test the conjecture for? ").then(ans => {
-    if (!isNaN(Number(ans))) {
-        const max = Int.from(ans), counterexmpls = getCounterExp(max);
-
-        if (counterexmpls.length == 0)
-            console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`);
-        else {
-            console.log("The conjecture is disproved! Here are the counter examples:");
-
-            let counterexmplsStr = "";
-            for (const pair of counterexmpls)
-                counterexmplsStr = `${counterexmplsStr}, (${pair[0]}, ${pair[1]})`;
-            
-            console.log(counterexmplsStr);
-        }
-    } else console.log(`'${ans}' is not an interger!`);
-}).catch(console.error);-
\ No newline at end of file
diff --git a/script.js b/script.js
@@ -9,7 +9,7 @@ Array.prototype.none = function() {
     return this.length == 0;
 }
 
-Number.prototype.getDigits = function() {
+Number.prototype.digits = function() {
     return Array.from(String(this)).map(char => Number(char));
 }
 
@@ -18,13 +18,7 @@ Number.prototype.divides = function(n) {
 }
 
 Number.prototype.sumDigits = function() {
-    let sum = 0;
-    const digits = this.getDigits();
-
-    for (n of digits)
-        sum += n;
-
-    return sum;
+    return this.digits().reduce((a, b) => a + b);
 }
 
 function askQuestion(query) {
@@ -56,11 +50,8 @@ function getCounterExp(max) {
         }
 
         for (b = a; b <= max; b++) {
-
             // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9
-            const conjectureHolds = (9).divides(
-                (a + b).sumDigits() - (a.sumDigits() + b.sumDigits())
-            );
+            const conjectureHolds = (9).divides((a + b).sumDigits() - (a.sumDigits() + b.sumDigits()));
             if (!conjectureHolds) counterexmpls.push([a, b]);
         }
     }
diff --git a/script.py b/script.py
@@ -6,32 +6,19 @@
 import sys
 import os
 import time
+from functools import reduce
 
 # A function for clearing the prompt
 clear = (lambda : os.system("cls")) if sys.platform.startswith("win") else (lambda : os.system("clear"))
 
-def is_multiple_of_nine(n):
-    return (n / 9) % 1 == 0
-
-def get_digits(n):
-    output = []
-
-    for ch in str(n):
-        output.append(int(ch))
-    
-    return output
+def digits(n):
+    return map(lambda c: int(c), list(str(n)))
 
 def sum_digits(n):
-    digits = get_digits(n)
-    output = 0
-
-    for d in digits:
-        output += d 
-    
-    return output
+    return reduce((lambda a, b: a + b), digits(n))
 
 def get_counterexmpls(n):
-    start_time = time.time()
+    start = time.time()
 
     load_bar = 0
     counterexmpls = []
@@ -42,18 +29,18 @@ def get_counterexmpls(n):
         if not round(a * 100 / n) == load_bar:
             load_bar = round(a * 100 / n)
             clear()
-            print("LOADING. . . %s%%" % load_bar)
+            print("LOADING. . . {}%".format(load_bar))
 
         for b in range(a, n + 1):
-            difference = sum_digits(a + b) - (sum_digits(a) + sum_digits(b))
+            diff = sum_digits(a + b) - (sum_digits(a) + sum_digits(b))
 
-            if not is_multiple_of_nine(difference):
+            if not diff % 9 == 0:
                 counterexmpls.append([a, b])
 
     # Mesure the elepsed time
-    elepsed_time = time.time() - start_time
+    elepsed = time.time() - start
     clear()
-    print("LOADED. . . %s%% in %ds\n" % (load_bar, elepsed_time))
+    print("LOADED. . . {}% in {}s\n".format(load_bar, elepsed))
     
     return counterexmpls    
 
@@ -71,14 +58,14 @@ try:
     counterexmpls = get_counterexmpls(maximum)
 
     if len(counterexmpls) == 0:
-        print("The conjecture is proved for all natural numbers smaller or equals to %s!" % maximum)
+        print("The conjecture is proved for all natural numbers smaller or equals to {}!".format(maximum))
     else:
         print("The conjecture is disproved! Here are the counter examples:")
 
         counterexmpls_str = ""
         for pair in counterexmpls:
-            counterexmpls_str = "%s, (%d, %f)" % (counterexmpls_str, pair[0], pair[1])
+            counterexmpls_str = "{}, ({}, {})".format(counterexmpls_str, pair[0], pair[1])
         
         print(counterexmpls_str)
 except:
-    print("'%s' isn't a valid number!" % user_input)
+    print("'{}' isn't a valid number!".format(user_input))
diff --git a/script.ts b/script.ts
@@ -5,108 +5,45 @@
 
 const readline = require('readline');
 
-class Int {
-    private val: number;
-
-    private constructor(n: number) {
-        this.val = n;
-    }
-
-    public add(n: Int): Int {
-        return new Int(this.val + n.val);
-    }
-
-    public subtrack(n: Int): Int {
-        return new Int(this.val - n.val);
-    }
-
-    public multiply(n: Int): Int {
-        return new Int(this.val * n.val);
-    }
-
-    public divide(n: Int): Int {
-        return new Int(Math.floor(this.val / n.val));
-    }
-
-    public incrementBy(n: Int) {
-        this.val += n.val;
-    }
-
-    public divides(n: Int): boolean {
-        return (n.val / this.val) % 1 == 0;
-    }
-
-    public getDigits(): Int[] {
-        return Array.from(this.val.toString()).map(char => Int.from(char));
-    }
-
-    public sumDigits(): Int {
-        let sum = Int.zero();
-        const digits = this.getDigits();
-
-        for (const n of digits)
-            sum.incrementBy(n);
-
-        return sum;
-    }
-
-    public toString(): string {
-        return `${this.val}`;
-    }
-
-    static from(a: number | string): Int {
-        return new Int(Math.round(Number(a)));
-    }
-
-    static getRange(a: Int, b: Int): Int[] {
-        const start = a.val, end = b.val, range: Int[] = [];
-
-        for (let i = start; i < end; i++) {
-            range.push(Int.from(i));
-        }
-
-        return range;
-    }
+function digits(n: number) {
+    return Array.from(Math.round(Math.abs(n)).toString()).map(c => parseInt(c));
+}
 
-    static zero(): Int {
-        return new Int(0);
-    }
+function sum(n: number) {
+    return digits(n).reduce((a, b) => a + b);
+}
 
-    static one(): Int {
-        return new Int(1);
-    }
+function test(a: number, b: number) {
+    return (sum(a + b) - (sum(a) + sum(b))) % 9 == 0;
 }
 
-function askQuestion(query: string) {
+function ask(question: string): Promise<string> {
     const rl = readline.createInterface({
         input: process.stdin,
         output: process.stdout,
     });
 
-    return new Promise((resolve: (value?: string | PromiseLike<string>) => void) => rl.question(query, (ans: string) => {
+    return new Promise(resolve => rl.question(question, (ans: string) => {
         rl.close();
         resolve(ans);
     }));
 }
 
-function getCounterExp(max: Int) {
-    const starTime = new Date(), counterexmpls: [Int, Int][] = [], nine = Int.from(9);
-    let loadBar = Int.zero();
+function getCounterExp(max: number) {
+    const starTime = new Date(), counterexmpls: [number, number][] = [];
+    let loadBar = 0;
 
-    for (const a of Int.getRange(Int.one(), max)) {
+    for (let a = 0; a <= max; a++) {
 
-        const newLoadBar = a.multiply(Int.from(100)).divide(max);
+        const newLoadBar = a * 100 / max;
         if (loadBar != newLoadBar) {
             console.clear();
             loadBar = newLoadBar;
             console.log(`LOADING. . . ${loadBar}%`);
         }
 
-        for (const b of Int.getRange(a, max)) {
-            // Check if the difference between S(a + b) and (S(a) + S(b)) is a multiple of 9
-            const conjectureHolds = nine.divides(a.add(b).sumDigits().subtrack(a.sumDigits().add(b.sumDigits())));
-            if (!conjectureHolds) counterexmpls.push([a, b]);
-        }
+        for (let b = a; b <= max; b++)
+            if (!test(a, b)) counterexmpls.push([a, b]);
     }
 
     const elepsedTime = (new Date().getTime() - starTime.getTime()) / 1000;
@@ -121,9 +58,9 @@ Let S: N -> N be the sum of the digits of a positive integer.
 For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
 `);
 
-askQuestion("What value would you like to test the conjecture for? ").then(ans => {
-    if (!isNaN(Number(ans))) {
-        const max = Int.from(ans), counterexmpls = getCounterExp(max);
+ask("What value would you like to test the conjecture for? ").then(ans => {
+    if (!isNaN(parseInt(ans))) {
+        const max = parseInt(ans), counterexmpls = getCounterExp(max);
 
         if (counterexmpls.length == 0)
             console.log(`The conjecture is proved for all natural numbers smaller or equals to ${max}!`);
diff --git a/script.ts.js b/script.ts.js
@@ -1 +1,4 @@
-const e=require("readline");class t{constructor(e){this.val=e}add(e){return new t(this.val+e.val)}subtrack(e){return new t(this.val-e.val)}multiply(e){return new t(this.val*e.val)}divide(e){return new t(Math.floor(this.val/e.val))}incrementBy(e){this.val+=e.val}divides(e){return e.val/this.val%1==0}getDigits(){return Array.from(this.val.toString()).map(e=>t.from(e))}sumDigits(){let e=t.zero();const o=this.getDigits();for(const t of o)e.incrementBy(t);return e}toString(){return`${this.val}`}static from(e){return new t(Math.round(Number(e)))}static getRange(e,o){const r=e.val,n=o.val,s=[];for(let e=r;e<n;e++)s.push(t.from(e));return s}static zero(){return new t(0)}static one(){return new t(1)}}console.log("This script is a simple test for the following conjecture:\n    \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(t){const o=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>o.question(t,t=>{o.close(),e(t)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(Number(e)))console.log(`'${e}' is not an interger!`);else{const o=t.from(e),r=function(e){const o=new Date,r=[],n=t.from(9);let s=t.zero();for(const o of t.getRange(t.one(),e)){const i=o.multiply(t.from(100)).divide(e);s!=i&&(console.clear(),s=i,console.log(`LOADING. . . ${s}%`));for(const s of t.getRange(o,e))n.divides(o.add(s).sumDigits().subtrack(o.sumDigits().add(s.sumDigits())))||r.push([o,s])}const i=((new Date).getTime()-o.getTime())/1e3;return console.clear(),console.log(`LOADED. . . ${s}% in ${i}s\n`),r}(o);if(0==r.length)console.log(`The conjecture is proved for all natural numbers smaller or equals to ${o}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(const t of r)e=`${e}, (${t[0]}, ${t[1]})`;console.log(e)}}}).catch(console.error);-
\ No newline at end of file
+// The following script is a simple test for the following conjecture:
+// Let S: N -> N be the sum of the digits of a positive integer.
+// For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.
+const e=require("readline");function o(e){return function(e){return Array.from(Math.round(Math.abs(e)).toString()).map(e=>parseInt(e))}(e).reduce((e,o)=>e+o)}function t(e,t){return(o(e+t)-(o(e)+o(t)))%9==0}console.log("This script is a simple test for the following conjecture:\n    \nLet S: N -> N be the sum of the digits of a positive integer.\nFor all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger.\n"),function(o){const t=e.createInterface({input:process.stdin,output:process.stdout});return new Promise(e=>t.question(o,o=>{t.close(),e(o)}))}("What value would you like to test the conjecture for? ").then(e=>{if(isNaN(parseInt(e)))console.log(`'${e}' is not an interger!`);else{const o=parseInt(e),n=function(e){const o=new Date,n=[];let r=0;for(let o=0;o<=e;o++){const s=100*o/e;r!=s&&(console.clear(),r=s,console.log(`LOADING. . . ${r}%`));for(let r=o;r<=e;r++)t(o,r)||n.push([o,r])}const s=((new Date).getTime()-o.getTime())/1e3;return console.clear(),console.log(`LOADED. . . ${r}% in ${s}s\n`),n}(o);if(0==n.length)console.log(`The conjecture is proved for all natural numbers smaller or equals to ${o}!`);else{console.log("The conjecture is disproved! Here are the counter examples:");let e="";for(const o of n)e=`${e}, (${o[0]}, ${o[1]})`;console.log(e)}}}).catch(console.error);+
\ No newline at end of file