Skip to content

ratajs/Advanced-Division-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Advanced-Division-py

Divide two numbers using recurring decimals

If you have Python installed, you can test this from the command line, such as py AdvDiv.py 1 7 or open the AdvDiv-demo.py file.

Import this library using import AdvDiv

Syntax: AdvDiv.div(n1, n2, minstr, decstr, str1, rstr2)

  • n1 – the first number
  • n2 – the second number
  • minstr – string representing the minus sign (default "-")
  • decstr – string separating the decimal digits (default ".")
  • rstr1 – string of the recursion beginning (default "[")
  • rstr2 – string of the recursion end (default "]")

Examples:

print(AdvDiv.div("1", "6"))

0.1[6]

print(AdvDiv.div("1", "7"))

0.[142857]

print(AdvDiv.div("123.1[24]", "7.54"))

16.[329475122578570854432923398440639819950164777750984647536371674302708785467406157061]

This code was created as a translation of my JavaScript library, so it should produce the same results. Learn more: https://advdiv.ratajs.cz