diff --git "a/all/amps_number_theory.json" "b/all/amps_number_theory.json" new file mode 100644--- /dev/null +++ "b/all/amps_number_theory.json" @@ -0,0 +1,101510 @@ +{ + "Source": [ + "AMPS.algebra.mathematica/number_theory/divisible" + ], + "Categories": [ + { + "Math complexity": 4, + "Language complexity": 1, + "Domain knowledge complexity": 3 + } + ], + "Instances": [ + { + "Input": "Problem:\nFind the smallest integer $m$ such that $478^m \\equiv 1 \\pmod{533}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(478, 533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1108$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1108 % -40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47182)$.", + "Output Answer": [ + "$22800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47182))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-659,-524,91\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -659, -524, 91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17499)$.", + "Output Answer": [ + "$11016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $564$ is divisible by $4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(564 % 4 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $729^m \\equiv 1 \\pmod{962}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(729, 962))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19968)$.", + "Output Answer": [ + "$6144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19968))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $244^517 \\pmod{1856}$.", + "Output Answer": [ + "$128$" + ], + "Output Program": [ + "print(pow(244, 517, 1856))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20511)$.", + "Output Answer": [ + "$13104$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20511))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{40952}{34523}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1611104105}-20476}{34523}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(40952/34523)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-9785$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9785 % -19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-16820$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-16820 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-667$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-667 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{4}$\n$x \\equiv 12 \\pmod{5}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (7, 4), (12, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 4), (12, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 4), (12, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $607x \\equiv 1 \\pmod{648}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "print(pow(607, -1, 648))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{9}$\n$x \\equiv 0 \\pmod{10}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "constraints = (12, 9), (0, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 9), (0, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 9), (0, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $355^m \\equiv 1 \\pmod{928}$.", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(355, 928))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{11}$\n$x \\equiv 19 \\pmod{5}$\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 9 \\pmod{18}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 11), (19, 5), (15, 2), (9, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 11), (19, 5), (15, 2), (9, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14560 \\pmod{33}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(14560 % 33)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $4519$.", + "Output Answer": [ + "$\\{3,6,7,11,12,13,14,15,19,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(4519):\n if len(roots) == 10: break\n if gcd(a, 4519) == 1 and is_primitive_root(a, 4519):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 5 \\pmod{13}$", + "Output Answer": [ + "$135$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 14), (5, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 14), (5, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (5, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3145)$.", + "Output Answer": [ + "$2304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10144}{29373}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{888498313}-5072}{29373}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10144/29373)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-341$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-341 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.01100110011001_3$ to base 10.", + "Output Answer": [ + "$0.15$" + ], + "Output Program": [ + "n = '0.01100110011001'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39151 \\pmod{74}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(39151 % 74)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15182)$.", + "Output Answer": [ + "$7590$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15182))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96557 \\pmod{39}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(96557 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1751^1910 \\pmod{2072}$.", + "Output Answer": [ + "$1513$" + ], + "Output Program": [ + "print(pow(1751, 1910, 2072))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $42727$.", + "Output Answer": [ + "$\\{3,5,6,11,17,20,21,24,29,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(42727):\n if len(roots) == 10: break\n if gcd(a, 42727) == 1 and is_primitive_root(a, 42727):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{31,-654,44\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 31, -654, 44\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10418)$.", + "Output Answer": [ + "$5208$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10418))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $86$ to base $18$.", + "Output Answer": [ + "$\\text{4e}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 86\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $175^m \\equiv 1 \\pmod{207}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(175, 207))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37203)$.", + "Output Answer": [ + "$24800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37203))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $175^m \\equiv 1 \\pmod{222}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(175, 222))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3860)$.", + "Output Answer": [ + "$1536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3860))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40439 \\pmod{70}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(40439 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11760$ is divisible by $49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-11760 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $79$ to base $18$.", + "Output Answer": [ + "$47_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 79\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $431^m \\equiv 1 \\pmod{978}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(431, 978))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $541^m \\equiv 1 \\pmod{653}$.", + "Output Answer": [ + "$326$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(541, 653))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2059^1812 \\pmod{2214}$.", + "Output Answer": [ + "$1477$" + ], + "Output Program": [ + "print(pow(2059, 1812, 2214))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{41,620,58\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 41, 620, 58\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{2}$\n$x \\equiv 4 \\pmod{10}$\n$x \\equiv 12 \\pmod{4}$\n$x \\equiv 20 \\pmod{12}$", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 2), (4, 10), (12, 4), (20, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 2), (4, 10), (12, 4), (20, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{548,625\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 548, 625\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9848}{12607}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{7327289}-4924}{12607}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9848/12607)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-595,627\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -595, 627\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{16}$\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 2 \\pmod{13}$", + "Output Answer": [ + "$171$" + ], + "Output Program": [ + "constraints = (11, 16), (11, 10), (2, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 16), (11, 10), (2, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-612,-297\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -612, -297\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1823$ to base $15$.", + "Output Answer": [ + "$818_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1823\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $401^2423 \\pmod{1785}$.", + "Output Answer": [ + "$1586$" + ], + "Output Program": [ + "print(pow(401, 2423, 1785))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $89^m \\equiv 1 \\pmod{264}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(89, 264))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{370}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 370))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $27690$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(27690 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n19921", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(19921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-763,916\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -763, 916\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.446$ to base $36$.", + "Output Answer": [ + "$\\text{0.g20l}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.446\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-103,-593\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -103, -593\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $5^m \\equiv 1 \\pmod{834}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(5, 834))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{639,711\\}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "import math\n\nvalues = 639, 711\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $425^596 \\pmod{2364}$.", + "Output Answer": [ + "$1801$" + ], + "Output Program": [ + "print(pow(425, 596, 2364))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4986 \\pmod{3}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(4986 % 3)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{974}$.", + "Output Answer": [ + "$486$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $917^1845 \\pmod{1045}$.", + "Output Answer": [ + "$837$" + ], + "Output Program": [ + "print(pow(917, 1845, 1045))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $597^295 \\pmod{2997}$.", + "Output Answer": [ + "$2349$" + ], + "Output Program": [ + "print(pow(597, 295, 2997))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-38496$ is divisible by $48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-38496 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n49205", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(49205))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $89^m \\equiv 1 \\pmod{386}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(89, 386))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{985}{3221}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{42469589}-985}{6442}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(985/3221)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29426$.", + "Output Answer": [ + "$\\{5,7,11,15,29,37,43,53,63,65\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29426):\n if len(roots) == 10: break\n if gcd(a, 29426) == 1 and is_primitive_root(a, 29426):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35153)$.", + "Output Answer": [ + "$35152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35153))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99659 \\pmod{81}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(99659 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{25990}{24569}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{772505786}-12995}{24569}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25990/24569)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2459^1947 \\pmod{2688}$.", + "Output Answer": [ + "$323$" + ], + "Output Program": [ + "print(pow(2459, 1947, 2688))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $27^1237 \\pmod{539}$.", + "Output Answer": [ + "$531$" + ], + "Output Program": [ + "print(pow(27, 1237, 539))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35550)$.", + "Output Answer": [ + "$9360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35550))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5415$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5415 % -15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{23197}{24783}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2994889165}-23197}{49566}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23197/24783)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{859,-88,79\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 859, -88, 79\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7886$.", + "Output Answer": [ + "$\\{3,5,7,39,45,51,53,59,65,69\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7886):\n if len(roots) == 10: break\n if gcd(a, 7886) == 1 and is_primitive_root(a, 7886):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9683}{29907}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3671475085}-9683}{59814}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9683/29907)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n28017", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(28017))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $508$ is divisible by $20$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(508 % 20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{672,870\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 672, 870\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $700^641 \\pmod{750}$.", + "Output Answer": [ + "$250$" + ], + "Output Program": [ + "print(pow(700, 641, 750))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34909)$.", + "Output Answer": [ + "$29916$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34909))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 6 \\pmod{13}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "constraints = (7, 3), (6, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 3), (6, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 3), (6, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47734 \\pmod{36}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(47734 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $71870$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 7187^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(71870))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $223^m \\equiv 1 \\pmod{344}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(223, 344))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-618,-532\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -618, -532\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2297^1612 \\pmod{2517}$.", + "Output Answer": [ + "$2194$" + ], + "Output Program": [ + "print(pow(2297, 1612, 2517))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9864)$.", + "Output Answer": [ + "$3264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9864))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1904x \\equiv 1 \\pmod{2063}$.", + "Output Answer": [ + "$1544$" + ], + "Output Program": [ + "print(pow(1904, -1, 2063))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n89769", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89769))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1336^1321 \\pmod{2656}$.", + "Output Answer": [ + "$2080$" + ], + "Output Program": [ + "print(pow(1336, 1321, 2656))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $557x \\equiv 1 \\pmod{1687}$.", + "Output Answer": [ + "$527$" + ], + "Output Program": [ + "print(pow(557, -1, 1687))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $108^m \\equiv 1 \\pmod{175}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(108, 175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{29}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 29))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33451)$.", + "Output Answer": [ + "$30400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33451))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $38882$.", + "Output Answer": [ + "$\\{13,17,29,39,41,43,51,59,61,65\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(38882):\n if len(roots) == 10: break\n if gcd(a, 38882) == 1 and is_primitive_root(a, 38882):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18142}{15617}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{326173730}-9071}{15617}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18142/15617)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{20}$\n$x \\equiv 9 \\pmod{18}$", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 20), (9, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 20), (9, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $201^m \\equiv 1 \\pmod{770}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(201, 770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{20}$\n$x \\equiv 10 \\pmod{14}$", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "constraints = (6, 20), (10, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 20), (10, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 8 \\pmod{15}$\n$x \\equiv 18 \\pmod{2}$", + "Output Answer": [ + "$1808$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 11), (0, 16), (8, 15), (18, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 11), (0, 16), (8, 15), (18, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $36473$.", + "Output Answer": [ + "$\\{3,5,6,7,10,11,13,14,19,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(36473):\n if len(roots) == 10: break\n if gcd(a, 36473) == 1 and is_primitive_root(a, 36473):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $391x \\equiv 1 \\pmod{2045}$.", + "Output Answer": [ + "$1386$" + ], + "Output Program": [ + "print(pow(391, -1, 2045))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{14}$\n$x \\equiv 6 \\pmod{14}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 14), (6, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 14), (6, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 19 \\pmod{12}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (15, 2), (19, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 2), (19, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $109^m \\equiv 1 \\pmod{843}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(109, 843))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{12}$\n$x \\equiv 8 \\pmod{11}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 12), (8, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 12), (8, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 12), (8, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15167)$.", + "Output Answer": [ + "$14616$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15167))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41983$.", + "Output Answer": [ + "$\\{6,10,12,14,17,20,26,28,33,34\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41983):\n if len(roots) == 10: break\n if gcd(a, 41983) == 1 and is_primitive_root(a, 41983):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83956 \\pmod{57}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(83956 % 57)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48878)$.", + "Output Answer": [ + "$24438$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48878))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $97504$.", + "Output Answer": [ + "$2^5\\cdot 11^1\\cdot 277^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(97504))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n75377", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(75377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $212^m \\equiv 1 \\pmod{761}$.", + "Output Answer": [ + "$152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(212, 761))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67546 \\pmod{23}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(67546 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $542$ to base $3$.", + "Output Answer": [ + "$202002_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 542\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $34733$.", + "Output Answer": [ + "$47^1\\cdot 739^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(34733))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1432}{7355}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{54608681}-716}{7355}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1432/7355)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $163$ is divisible by $13$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(163 % 13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-296$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-296 % -37 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 7 \\pmod{7}$", + "Output Answer": [ + "$91$" + ], + "Output Program": [ + "constraints = (6, 17), (7, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (7, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 17), (7, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1336$ is divisible by $8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1336 % 8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{732,630\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 732, 630\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13644}{8437}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{117722653}-6822}{8437}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13644/8437)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1140$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1140 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44108 \\pmod{34}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(44108 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37985)$.", + "Output Answer": [ + "$29680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37985))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $174^m \\equiv 1 \\pmod{409}$.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(174, 409))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{745,398\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 745, 398\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $76^m \\equiv 1 \\pmod{127}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(76, 127))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{961,-87,20\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 961, -87, 20\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1251^303 \\pmod{1596}$.", + "Output Answer": [ + "$615$" + ], + "Output Program": [ + "print(pow(1251, 303, 1596))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $379x \\equiv 1 \\pmod{2071}$.", + "Output Answer": [ + "$1918$" + ], + "Output Program": [ + "print(pow(379, -1, 2071))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40378 \\pmod{54}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(40378 % 54)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18051}{12088}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{910317577}-18051}{24176}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18051/12088)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4190}{1437}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6453994}-2095}{1437}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4190/1437)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-88,40\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -88, 40\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23335)$.", + "Output Answer": [ + "$17184$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23335))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16507 \\pmod{9}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(16507 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28285)$.", + "Output Answer": [ + "$22624$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28285))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{365,611\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 365, 611\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47585)$.", + "Output Answer": [ + "$36720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47585))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46764)$.", + "Output Answer": [ + "$15552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1655x \\equiv 1 \\pmod{1936}$.", + "Output Answer": [ + "$999$" + ], + "Output Program": [ + "print(pow(1655, -1, 1936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $39x \\equiv 1 \\pmod{1240}$.", + "Output Answer": [ + "$159$" + ], + "Output Program": [ + "print(pow(39, -1, 1240))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{864,443,545\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 864, 443, 545\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $114^m \\equiv 1 \\pmod{959}$.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(114, 959))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38371 \\pmod{69}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(38371 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-983,-525,142\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -983, -525, 142\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{410}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 410))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.415$ to base $20$.", + "Output Answer": [ + "$0.86_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.415\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44601)$.", + "Output Answer": [ + "$29732$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44601))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11729)$.", + "Output Answer": [ + "$11376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11729))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29860 \\pmod{10}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(29860 % 10)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-3,-1,5\\}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -3, -1, 5\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14517}{6838}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{397776265}-14517}{13676}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14517/6838)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $194^m \\equiv 1 \\pmod{357}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(194, 357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-10727$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10727 % -17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-25428$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-25428 % -26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $949$ to base $29$.", + "Output Answer": [ + "$\\text{13l}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 949\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{36353}{18017}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2619989765}-36353}{36034}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36353/18017)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-6540$ is divisible by $36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-6540 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2101^44 \\pmod{2522}$.", + "Output Answer": [ + "$2133$" + ], + "Output Program": [ + "print(pow(2101, 44, 2522))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $79360$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(79360 % -40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $25^1694 \\pmod{1241}$.", + "Output Answer": [ + "$990$" + ], + "Output Program": [ + "print(pow(25, 1694, 1241))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 11 \\pmod{16}$\n$x \\equiv 4 \\pmod{19}$", + "Output Answer": [ + "$251$" + ], + "Output Program": [ + "constraints = (11, 10), (11, 16), (4, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 10), (11, 16), (4, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $625^m \\equiv 1 \\pmod{762}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(625, 762))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{415}$.", + "Output Answer": [ + "$164$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 415))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1593^627 \\pmod{2742}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(1593, 627, 2742))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{199}{234}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{468} \\left(5 \\sqrt{10345}-199\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(199/234)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $367x \\equiv 1 \\pmod{1860}$.", + "Output Answer": [ + "$223$" + ], + "Output Program": [ + "print(pow(367, -1, 1860))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1553$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1553 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49877)$.", + "Output Answer": [ + "$49876$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49877))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30522)$.", + "Output Answer": [ + "$10172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30522))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{505,66\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 505, 66\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{33,970,-52\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 33, 970, -52\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $211x \\equiv 1 \\pmod{514}$.", + "Output Answer": [ + "$419$" + ], + "Output Program": [ + "print(pow(211, -1, 514))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1738)$.", + "Output Answer": [ + "$780$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $32x \\equiv 1 \\pmod{189}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(pow(32, -1, 189))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2384^1675 \\pmod{2466}$.", + "Output Answer": [ + "$188$" + ], + "Output Program": [ + "print(pow(2384, 1675, 2466))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{0,809\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 0, 809\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $351^m \\equiv 1 \\pmod{584}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(351, 584))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $19472$.", + "Output Answer": [ + "$2^4\\cdot 1217^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(19472))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1426^1390 \\pmod{1684}$.", + "Output Answer": [ + "$964$" + ], + "Output Program": [ + "print(pow(1426, 1390, 1684))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{13}$\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 18 \\pmod{2}$\n$x \\equiv 9 \\pmod{7}$", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 13), (16, 2), (18, 2), (9, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 13), (16, 2), (18, 2), (9, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30256}{27797}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1001529593}-15128}{27797}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30256/27797)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 13 \\pmod{16}$\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 10 \\pmod{15}$", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "constraints = (10, 13), (13, 16), (7, 11), (10, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 13), (13, 16), (7, 11), (10, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 13), (13, 16), (7, 11), (10, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(669)$.", + "Output Answer": [ + "$444$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(669))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{9}$\n$x \\equiv 17 \\pmod{6}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 9), (17, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 9), (17, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $191x \\equiv 1 \\pmod{444}$.", + "Output Answer": [ + "$179$" + ], + "Output Program": [ + "print(pow(191, -1, 444))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25960)$.", + "Output Answer": [ + "$9280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25960))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $711^1722 \\pmod{2284}$.", + "Output Answer": [ + "$2097$" + ], + "Output Program": [ + "print(pow(711, 1722, 2284))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3533}{3660}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{66064489}-3533}{7320}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3533/3660)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-121,-82\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -121, -82\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $416$ is divisible by $32$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(416 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{36077}{18395}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2655054029}-36077}{36790}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36077/18395)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.825$ to base $28$.", + "Output Answer": [ + "$\\text{0.n2mb}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.825\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $183^m \\equiv 1 \\pmod{304}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(183, 304))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1528x \\equiv 1 \\pmod{2327}$.", + "Output Answer": [ + "$964$" + ], + "Output Program": [ + "print(pow(1528, -1, 2327))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $764x \\equiv 1 \\pmod{847}$.", + "Output Answer": [ + "$449$" + ], + "Output Program": [ + "print(pow(764, -1, 847))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47708)$.", + "Output Answer": [ + "$23852$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47708))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $30$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(30 % 5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33163)$.", + "Output Answer": [ + "$30600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33163))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{931,-913,347\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 931, -913, 347\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $106x \\equiv 1 \\pmod{129}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(pow(106, -1, 129))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{398,461,-821\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 398, 461, -821\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $32063$.", + "Output Answer": [ + "$\\{5,10,11,13,15,20,22,23,26,29\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(32063):\n if len(roots) == 10: break\n if gcd(a, 32063) == 1 and is_primitive_root(a, 32063):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $182x \\equiv 1 \\pmod{405}$.", + "Output Answer": [ + "$158$" + ], + "Output Program": [ + "print(pow(182, -1, 405))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{13}$\n$x \\equiv 14 \\pmod{10}$", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 13), (14, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 13), (14, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 13), (14, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92881 \\pmod{26}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(92881 % 26)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $37799$.", + "Output Answer": [ + "$37799^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37799))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 19 \\pmod{11}$\n$x \\equiv 1 \\pmod{2}$", + "Output Answer": [ + "$789$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 17), (15, 3), (19, 11), (1, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 17), (15, 3), (19, 11), (1, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 17), (15, 3), (19, 11), (1, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 1 \\pmod{2}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "constraints = (18, 5), (1, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 5), (1, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 5), (1, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 7 \\pmod{5}$", + "Output Answer": [ + "$902$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 17), (11, 11), (7, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 17), (11, 11), (7, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 17), (11, 11), (7, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{10}$\n$x \\equiv 17 \\pmod{8}$\n$x \\equiv 13 \\pmod{2}$\n$x \\equiv 13 \\pmod{9}$", + "Output Answer": [ + "$193$" + ], + "Output Program": [ + "constraints = (3, 10), (17, 8), (13, 2), (13, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 10), (17, 8), (13, 2), (13, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2767$ to base $34$.", + "Output Answer": [ + "$\\text{2dd}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2767\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1059^2199 \\pmod{2003}$.", + "Output Answer": [ + "$1363$" + ], + "Output Program": [ + "print(pow(1059, 2199, 2003))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2223$ to base $14$.", + "Output Answer": [ + "$\\text{b4b}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2223\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97010 \\pmod{66}$.", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "print(97010 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{425,-984,-207\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 425, -984, -207\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{874,-719\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 874, -719\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n27985", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(27985))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{23,640,88\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 23, 640, 88\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $745x \\equiv 1 \\pmod{2373}$.", + "Output Answer": [ + "$2287$" + ], + "Output Program": [ + "print(pow(745, -1, 2373))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $936^1264 \\pmod{1770}$.", + "Output Answer": [ + "$1056$" + ], + "Output Program": [ + "print(pow(936, 1264, 1770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-826,-355,223\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -826, -355, 223\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $343^m \\equiv 1 \\pmod{676}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(343, 676))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{177,-178,-329\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 177, -178, -329\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $531^m \\equiv 1 \\pmod{562}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(531, 562))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{484}{233}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{233} \\left(\\sqrt{112853}-242\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(484/233)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5552$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5552 % -16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,5,0,2\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 5, 0, 2\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2285^261 \\pmod{2974}$.", + "Output Answer": [ + "$1389$" + ], + "Output Program": [ + "print(pow(2285, 261, 2974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1755^1589 \\pmod{2104}$.", + "Output Answer": [ + "$1795$" + ], + "Output Program": [ + "print(pow(1755, 1589, 2104))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31121)$.", + "Output Answer": [ + "$31120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $22^661 \\pmod{2927}$.", + "Output Answer": [ + "$658$" + ], + "Output Program": [ + "print(pow(22, 661, 2927))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n8375", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(8375))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35700)$.", + "Output Answer": [ + "$7680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35700))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29922)$.", + "Output Answer": [ + "$9972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29922))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-990,-490,293\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -990, -490, 293\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1974$ to base $8$.", + "Output Answer": [ + "$3666_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1974\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $479^2315 \\pmod{650}$.", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "print(pow(479, 2315, 650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-488,-216,209\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -488, -216, 209\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1419^2287 \\pmod{2051}$.", + "Output Answer": [ + "$1475$" + ], + "Output Program": [ + "print(pow(1419, 2287, 2051))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.272$ to base $28$.", + "Output Answer": [ + "$\\text{0.7h6q}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.272\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1338^321 \\pmod{1821}$.", + "Output Answer": [ + "$1284$" + ], + "Output Program": [ + "print(pow(1338, 321, 1821))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $152^m \\equiv 1 \\pmod{479}$.", + "Output Answer": [ + "$478$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(152, 479))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{14}$\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 10 \\pmod{4}$", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 14), (6, 5), (10, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 14), (6, 5), (10, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{4,-1,1,-5\\}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nvalues = 4, -1, 1, -5\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86038 \\pmod{84}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(86038 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93572 \\pmod{41}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(93572 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37436)$.", + "Output Answer": [ + "$15960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37436))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{79}{480}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{960} \\left(\\sqrt{927841}-79\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(79/480)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6149}{4857}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{132171997}-6149}{9714}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6149/4857)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(455)$.", + "Output Answer": [ + "$288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(455))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48734)$.", + "Output Answer": [ + "$20532$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48734))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1990$ is divisible by $46$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1990 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{895}$.", + "Output Answer": [ + "$178$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 895))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11490}{4429}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{52621066}-5745}{4429}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11490/4429)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-872,407\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -872, 407\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{706,-760\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 706, -760\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $212x \\equiv 1 \\pmod{1775}$.", + "Output Answer": [ + "$1348$" + ], + "Output Program": [ + "print(pow(212, -1, 1775))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24642)$.", + "Output Answer": [ + "$7992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.1222200222111_3$ to base 10.", + "Output Answer": [ + "$0.663$" + ], + "Output Program": [ + "n = '0.1222200222111'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-36,-408\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -36, -408\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n6619", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $286^m \\equiv 1 \\pmod{543}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(286, 543))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82812 \\pmod{91}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(82812 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{9}$\n$x \\equiv 4 \\pmod{2}$", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 9), (4, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 9), (4, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 9), (4, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-928$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-928 % -44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 13 \\pmod{14}$", + "Output Answer": [ + "$265$" + ], + "Output Program": [ + "constraints = (18, 19), (13, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 19), (13, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (13, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-659$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-659 % -15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 9 \\pmod{17}$", + "Output Answer": [ + "$230$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 3), (15, 5), (6, 14), (9, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 3), (15, 5), (6, 14), (9, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 3), (15, 5), (6, 14), (9, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11303 \\pmod{67}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(11303 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $99925$.", + "Output Answer": [ + "$5^2\\cdot 7^1\\cdot 571^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(99925))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-12142$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-12142 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n66219", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66219))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52980 \\pmod{91}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(52980 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{154,21,-227\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 154, 21, -227\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $96527$.", + "Output Answer": [ + "$96527^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(96527))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $131x \\equiv 1 \\pmod{160}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(131, -1, 160))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43257 \\pmod{42}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(43257 % 42)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71661", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71661))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-529,802\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -529, 802\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $86^m \\equiv 1 \\pmod{391}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(86, 391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n38463", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(38463))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16259 \\pmod{64}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(16259 % 64)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16814)$.", + "Output Answer": [ + "$7200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16814))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $488x \\equiv 1 \\pmod{1529}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(pow(488, -1, 1529))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16771 \\pmod{36}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(16771 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $380x \\equiv 1 \\pmod{1603}$.", + "Output Answer": [ + "$1236$" + ], + "Output Program": [ + "print(pow(380, -1, 1603))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2260^1254 \\pmod{2540}$.", + "Output Answer": [ + "$200$" + ], + "Output Program": [ + "print(pow(2260, 1254, 2540))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{9}$\n$x \\equiv 13 \\pmod{16}$", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 9), (13, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 9), (13, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 9), (13, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20974)$.", + "Output Answer": [ + "$10486$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $232$ is divisible by $14$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(232 % 14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1843$ to base $3$.", + "Output Answer": [ + "$2112021_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1843\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 3 \\pmod{14}$", + "Output Answer": [ + "$185$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 15), (3, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 15), (3, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 15), (3, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $98604$.", + "Output Answer": [ + "$2^2\\cdot 3^3\\cdot 11^1\\cdot 83^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(98604))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1152$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1152 % 27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n60337", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60337))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{471,406\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 471, 406\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1078x \\equiv 1 \\pmod{1185}$.", + "Output Answer": [ + "$742$" + ], + "Output Program": [ + "print(pow(1078, -1, 1185))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $11789$.", + "Output Answer": [ + "$\\{2,3,8,10,11,12,13,15,18,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(11789):\n if len(roots) == 10: break\n if gcd(a, 11789) == 1 and is_primitive_root(a, 11789):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14921)$.", + "Output Answer": [ + "$14532$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3019}{3096}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1898209}-3019}{6192}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3019/3096)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{82,-874,39\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 82, -874, 39\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13723}{17001}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1344456733}-13723}{34002}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13723/17001)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31136)$.", + "Output Answer": [ + "$13248$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31136))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n11617", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(11617))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1354$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1354 % -32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1008^522 \\pmod{2261}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(pow(1008, 522, 2261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,1,-1,-1\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -1, 1, -1, -1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 4 \\pmod{11}$", + "Output Answer": [ + "$1291$" + ], + "Output Program": [ + "constraints = (11, 10), (16, 17), (4, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 10), (16, 17), (4, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 10), (16, 17), (4, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $27817$.", + "Output Answer": [ + "$\\{5,7,17,20,23,28,34,40,43,46\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(27817):\n if len(roots) == 10: break\n if gcd(a, 27817) == 1 and is_primitive_root(a, 27817):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87280 \\pmod{35}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(87280 % 35)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $30x \\equiv 1 \\pmod{637}$.", + "Output Answer": [ + "$361$" + ], + "Output Program": [ + "print(pow(30, -1, 637))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1010^1244 \\pmod{2965}$.", + "Output Answer": [ + "$1705$" + ], + "Output Program": [ + "print(pow(1010, 1244, 2965))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $219^m \\equiv 1 \\pmod{650}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(219, 650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1151}{2622}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{28824337}-1151}{5244}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1151/2622)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $861$ to base $33$.", + "Output Answer": [ + "$\\text{q3}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 861\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1261 \\pmod{66}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(1261 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $951$ to base $15$.", + "Output Answer": [ + "$436_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 951\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1251^2359 \\pmod{2601}$.", + "Output Answer": [ + "$396$" + ], + "Output Program": [ + "print(pow(1251, 2359, 2601))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2389}{35658}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5091679177}-2389}{71316}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2389/35658)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-761,-191\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -761, -191\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{4}$\n$x \\equiv 17 \\pmod{9}$\n$x \\equiv 8 \\pmod{8}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "constraints = (0, 4), (17, 9), (8, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 4), (17, 9), (8, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22125)$.", + "Output Answer": [ + "$11600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22125))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $57^1918 \\pmod{2647}$.", + "Output Answer": [ + "$1111$" + ], + "Output Program": [ + "print(pow(57, 1918, 2647))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-653,446,569\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -653, 446, 569\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-133$ is divisible by $5$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-133 % 5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30136}{24387}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{821770393}-15068}{24387}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30136/24387)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $196$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(196 % -8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $91^m \\equiv 1 \\pmod{135}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(91, 135))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n81371", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(81371))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2039^2034 \\pmod{2922}$.", + "Output Answer": [ + "$301$" + ], + "Output Program": [ + "print(pow(2039, 2034, 2922))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $674^m \\equiv 1 \\pmod{867}$.", + "Output Answer": [ + "$272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(674, 867))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2322$ to base $2$.", + "Output Answer": [ + "$100100010010_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2322\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $202x \\equiv 1 \\pmod{291}$.", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "print(pow(202, -1, 291))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23168 \\pmod{93}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(23168 % 93)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 95117 \\pmod{4}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(95117 % 4)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $257^m \\equiv 1 \\pmod{732}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(257, 732))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50275 \\pmod{74}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(50275 % 74)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{75,-357\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 75, -357\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 12 \\pmod{6}$\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$750$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (12, 6), (15, 5), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 18), (12, 6), (15, 5), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2887}{23868}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2287060465}-2887}{47736}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2887/23868)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $996x \\equiv 1 \\pmod{1553}$.", + "Output Answer": [ + "$329$" + ], + "Output Program": [ + "print(pow(996, -1, 1553))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{23720}{10903}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{259535009}-11860}{10903}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23720/10903)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $413^m \\equiv 1 \\pmod{766}$.", + "Output Answer": [ + "$382$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(413, 766))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n45053", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(45053))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{5}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "constraints = (19, 5), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 5), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 5), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4700$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4700 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $43468$.", + "Output Answer": [ + "$2^2\\cdot 10867^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(43468))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25990 \\pmod{84}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(25990 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{922,-383\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 922, -383\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18886)$.", + "Output Answer": [ + "$7560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18886))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $829^1709 \\pmod{1234}$.", + "Output Answer": [ + "$985$" + ], + "Output Program": [ + "print(pow(829, 1709, 1234))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $604^1504 \\pmod{963}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "print(pow(604, 1504, 963))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $46118$.", + "Output Answer": [ + "$2^1\\cdot 23059^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(46118))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $10^m \\equiv 1 \\pmod{423}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(10, 423))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4406)$.", + "Output Answer": [ + "$2202$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4406))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $20537$.", + "Output Answer": [ + "$11^1\\cdot 1867^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(20537))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39692)$.", + "Output Answer": [ + "$19844$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39692))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31977)$.", + "Output Answer": [ + "$17280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31977))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-641,-466\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -641, -466\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $4x \\equiv 1 \\pmod{155}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(pow(4, -1, 155))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{39,0,94\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 39, 0, 94\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{357}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $99^m \\equiv 1 \\pmod{731}$.", + "Output Answer": [ + "$336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(99, 731))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $177x \\equiv 1 \\pmod{806}$.", + "Output Answer": [ + "$551$" + ], + "Output Program": [ + "print(pow(177, -1, 806))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $7560$ is divisible by $45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7560 % 45 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $369^m \\equiv 1 \\pmod{544}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(369, 544))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1017^1012 \\pmod{2552}$.", + "Output Answer": [ + "$1785$" + ], + "Output Program": [ + "print(pow(1017, 1012, 2552))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n83593", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83593))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48187)$.", + "Output Answer": [ + "$48186$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48187))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $659^m \\equiv 1 \\pmod{864}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(659, 864))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $230x \\equiv 1 \\pmod{1163}$.", + "Output Answer": [ + "$268$" + ], + "Output Program": [ + "print(pow(230, -1, 1163))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12419}{26342}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2929835417}-12419}{52684}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12419/26342)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91316 \\pmod{32}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(91316 % 32)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16011)$.", + "Output Answer": [ + "$10656$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16011))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-114$ is divisible by $10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-114 % 10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{9}$\n$x \\equiv 16 \\pmod{19}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 9), (16, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 9), (16, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 9), (16, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n52553", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(52553))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $513^m \\equiv 1 \\pmod{868}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(513, 868))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n42171", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(42171))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $34654$.", + "Output Answer": [ + "$\\{5,7,13,15,21,23,29,39,43,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(34654):\n if len(roots) == 10: break\n if gcd(a, 34654) == 1 and is_primitive_root(a, 34654):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n8941", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(8941))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1188}{433}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{433} \\left(5 \\sqrt{21613}-594\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1188/433)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{4}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "constraints = (13, 4), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 4), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 4), (11, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $14x \\equiv 1 \\pmod{27}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(pow(14, -1, 27))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{473,231\\}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "import math\n\nvalues = 473, 231\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n39395", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(39395))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43374 \\pmod{74}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(43374 % 74)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $43781$.", + "Output Answer": [ + "$\\{2,7,8,10,12,17,22,35,38,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(43781):\n if len(roots) == 10: break\n if gcd(a, 43781) == 1 and is_primitive_root(a, 43781):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $3387$.", + "Output Answer": [ + "$3^1\\cdot 1129^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(3387))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1861}{4824}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{3861889}-1861}{9648}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1861/4824)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $99x \\equiv 1 \\pmod{1600}$.", + "Output Answer": [ + "$1099$" + ], + "Output Program": [ + "print(pow(99, -1, 1600))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28917)$.", + "Output Answer": [ + "$15552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28917))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24642 \\pmod{24}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(24642 % 24)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11192}{3837}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46037785}-5596}{3837}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11192/3837)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11362)$.", + "Output Answer": [ + "$4752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11362))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $224x \\equiv 1 \\pmod{323}$.", + "Output Answer": [ + "$261$" + ], + "Output Program": [ + "print(pow(224, -1, 323))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n101573", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101573))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-654,295\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -654, 295\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1587x \\equiv 1 \\pmod{2258}$.", + "Output Answer": [ + "$1235$" + ], + "Output Program": [ + "print(pow(1587, -1, 2258))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33438 \\pmod{31}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(33438 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2010$ to base $14$.", + "Output Answer": [ + "$\\text{a38}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2010\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7369$.", + "Output Answer": [ + "$\\{7,13,14,21,26,28,29,31,39,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7369):\n if len(roots) == 10: break\n if gcd(a, 7369) == 1 and is_primitive_root(a, 7369):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-333,811,-471\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -333, 811, -471\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $315x \\equiv 1 \\pmod{1186}$.", + "Output Answer": [ + "$561$" + ], + "Output Program": [ + "print(pow(315, -1, 1186))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10614)$.", + "Output Answer": [ + "$3360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10614))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1964^2118 \\pmod{2192}$.", + "Output Answer": [ + "$1712$" + ], + "Output Program": [ + "print(pow(1964, 2118, 2192))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68022 \\pmod{61}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(68022 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8011$.", + "Output Answer": [ + "$\\{14,26,38,43,46,51,53,56,57,59\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8011):\n if len(roots) == 10: break\n if gcd(a, 8011) == 1 and is_primitive_root(a, 8011):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2640$ is divisible by $-24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2640 % -24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{15829}{20122}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1870136777}-15829}{40244}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15829/20122)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $794$ to base $19$.", + "Output Answer": [ + "$\\text{23f}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 794\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89261 \\pmod{61}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(89261 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5297}{27261}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3000706693}-5297}{54522}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5297/27261)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $677$ to base $28$.", + "Output Answer": [ + "$\\text{o5}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 677\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 16 \\pmod{16}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 3), (16, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 3), (16, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 3), (16, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10478)$.", + "Output Answer": [ + "$4680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10478))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-999,513\\}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "import math\n\nvalues = -999, 513\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37434)$.", + "Output Answer": [ + "$11712$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37434))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{14}$\n$x \\equiv 7 \\pmod{13}$\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 16 \\pmod{15}$", + "Output Answer": [ + "$20716$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 14), (7, 13), (6, 19), (16, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 14), (7, 13), (6, 19), (16, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 14), (7, 13), (6, 19), (16, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $406^m \\equiv 1 \\pmod{459}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(406, 459))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6175)$.", + "Output Answer": [ + "$4320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4596 \\pmod{52}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(4596 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7710)$.", + "Output Answer": [ + "$2048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7710))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $928^408 \\pmod{1381}$.", + "Output Answer": [ + "$339$" + ], + "Output Program": [ + "print(pow(928, 408, 1381))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.19$ to base $8$.", + "Output Answer": [ + "$0.1412173_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.19\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{894,-151\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 894, -151\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12090)$.", + "Output Answer": [ + "$2880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12090))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9932 \\pmod{66}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(9932 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8473}{5908}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{211409585}-8473}{11816}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8473/5908)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3368}{7517}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{59341145}-1684}{7517}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3368/7517)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88237 \\pmod{3}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(88237 % 3)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,3,1\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = -1, 3, 1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39028 \\pmod{41}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(39028 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-168$ is divisible by $36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-168 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{14}$\n$x \\equiv 15 \\pmod{18}$\n$x \\equiv 13 \\pmod{10}$\n$x \\equiv 18 \\pmod{11}$", + "Output Answer": [ + "$4803$" + ], + "Output Program": [ + "constraints = (1, 14), (15, 18), (13, 10), (18, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 14), (15, 18), (13, 10), (18, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $405x \\equiv 1 \\pmod{733}$.", + "Output Answer": [ + "$476$" + ], + "Output Program": [ + "print(pow(405, -1, 733))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $9^m \\equiv 1 \\pmod{227}$.", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(9, 227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1448_{13}$ to base 10.", + "Output Answer": [ + "$2933$" + ], + "Output Program": [ + "n = '1448'.strip('.')\nbase = 13\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 10 \\pmod{6}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 3), (10, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 3), (10, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $157^m \\equiv 1 \\pmod{682}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(157, 682))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{15675}{14887}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1132196701}-15675}{29774}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15675/14887)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{172,107,-919\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 172, 107, -919\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-229$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-229 % -8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2333^592 \\pmod{2581}$.", + "Output Answer": [ + "$1591$" + ], + "Output Program": [ + "print(pow(2333, 592, 2581))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{8}$\n$x \\equiv 6 \\pmod{4}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 8), (6, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 8), (6, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n96295", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(96295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{33526}{16491}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{25 \\sqrt{884722}-16763}{16491}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33526/16491)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25462)$.", + "Output Answer": [ + "$12264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46024 \\pmod{3}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(46024 % 3)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $277x \\equiv 1 \\pmod{2360}$.", + "Output Answer": [ + "$213$" + ], + "Output Program": [ + "print(pow(277, -1, 2360))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{13}$\n$x \\equiv 6 \\pmod{3}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 19 \\pmod{10}$", + "Output Answer": [ + "$759$" + ], + "Output Program": [ + "constraints = (5, 13), (6, 3), (3, 4), (19, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 13), (6, 3), (3, 4), (19, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64082 \\pmod{99}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(64082 % 99)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-625,-866\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -625, -866\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n25031", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(25031))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49290)$.", + "Output Answer": [ + "$12480$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49290))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-318,115,-387\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -318, 115, -387\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $524^m \\equiv 1 \\pmod{845}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(524, 845))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24487)$.", + "Output Answer": [ + "$23920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24487))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1069$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1069 % 27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 15 \\pmod{14}$\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 3 \\pmod{16}$", + "Output Answer": [ + "$17459$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 17), (15, 14), (14, 15), (3, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 17), (15, 14), (14, 15), (3, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2322^1868 \\pmod{2406}$.", + "Output Answer": [ + "$780$" + ], + "Output Program": [ + "print(pow(2322, 1868, 2406))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $415^m \\equiv 1 \\pmod{956}$.", + "Output Answer": [ + "$238$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(415, 956))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $323x \\equiv 1 \\pmod{326}$.", + "Output Answer": [ + "$217$" + ], + "Output Program": [ + "print(pow(323, -1, 326))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1138^1906 \\pmod{1537}$.", + "Output Answer": [ + "$861$" + ], + "Output Program": [ + "print(pow(1138, 1906, 1537))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 18 \\pmod{13}$", + "Output Answer": [ + "$135$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 11), (18, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 11), (18, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 11), (18, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $5x \\equiv 1 \\pmod{63}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(pow(5, -1, 63))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n54317", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54317))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29102$.", + "Output Answer": [ + "$\\{3,11,15,39,61,69,77,93,95,101\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29102):\n if len(roots) == 10: break\n if gcd(a, 29102) == 1 and is_primitive_root(a, 29102):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $409x \\equiv 1 \\pmod{1060}$.", + "Output Answer": [ + "$749$" + ], + "Output Program": [ + "print(pow(409, -1, 1060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $11326$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(11326 % 28 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $40542$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(40542 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $275^m \\equiv 1 \\pmod{576}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(275, 576))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 10 \\pmod{12}$\n$x \\equiv 10 \\pmod{11}$", + "Output Answer": [ + "$142$" + ], + "Output Program": [ + "constraints = (6, 17), (10, 12), (10, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (10, 12), (10, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 17), (10, 12), (10, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1021^865 \\pmod{2868}$.", + "Output Answer": [ + "$1729$" + ], + "Output Program": [ + "print(pow(1021, 865, 2868))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1034^2497 \\pmod{1779}$.", + "Output Answer": [ + "$194$" + ], + "Output Program": [ + "print(pow(1034, 2497, 1779))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $209^299 \\pmod{1119}$.", + "Output Answer": [ + "$239$" + ], + "Output Program": [ + "print(pow(209, 299, 1119))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{12}$\n$x \\equiv 0 \\pmod{18}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (6, 12), (0, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 12), (0, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 12 \\pmod{16}$\n$x \\equiv 4 \\pmod{9}$\n$x \\equiv 1 \\pmod{7}$", + "Output Answer": [ + "$8716$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 13), (12, 16), (4, 9), (1, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 13), (12, 16), (4, 9), (1, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 13), (12, 16), (4, 9), (1, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2710$ to base $20$.", + "Output Answer": [ + "$\\text{6fa}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2710\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{19}$\n$x \\equiv 16 \\pmod{10}$", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 19), (16, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 19), (16, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 19), (16, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30901)$.", + "Output Answer": [ + "$28512$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30901))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1903x \\equiv 1 \\pmod{2275}$.", + "Output Answer": [ + "$1217$" + ], + "Output Program": [ + "print(pow(1903, -1, 2275))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{3}$\n$x \\equiv 13 \\pmod{10}$\n$x \\equiv 15 \\pmod{19}$", + "Output Answer": [ + "$243$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 3), (13, 10), (15, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 3), (13, 10), (15, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 3), (13, 10), (15, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{446,908\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 446, 908\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1271x \\equiv 1 \\pmod{2229}$.", + "Output Answer": [ + "$1994$" + ], + "Output Program": [ + "print(pow(1271, -1, 2229))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $37^m \\equiv 1 \\pmod{482}$.", + "Output Answer": [ + "$240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(37, 482))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.1_{25}$ to base 10.", + "Output Answer": [ + "$0.04$" + ], + "Output Program": [ + "n = '0.1'.strip('.')\nbase = 25\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32921)$.", + "Output Answer": [ + "$28212$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 11 \\pmod{3}$", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "constraints = (14, 15), (11, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 15), (11, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-78980$ is divisible by $44$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-78980 % 44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{656,623,923\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 656, 623, 923\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9445)$.", + "Output Answer": [ + "$7552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 17 \\pmod{17}$", + "Output Answer": [ + "$255$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (17, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 19), (17, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 19), (17, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44387", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44387))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3778)$.", + "Output Answer": [ + "$1888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3778))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{9}$\n$x \\equiv 8 \\pmod{14}$", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 9), (8, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 9), (8, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 9), (8, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $544x \\equiv 1 \\pmod{565}$.", + "Output Answer": [ + "$269$" + ], + "Output Program": [ + "print(pow(544, -1, 565))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1589^362 \\pmod{1885}$.", + "Output Answer": [ + "$1881$" + ], + "Output Program": [ + "print(pow(1589, 362, 1885))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{871,-883\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 871, -883\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n99905", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(99905))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $402^m \\equiv 1 \\pmod{925}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(402, 925))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $746x \\equiv 1 \\pmod{1421}$.", + "Output Answer": [ + "$1381$" + ], + "Output Program": [ + "print(pow(746, -1, 1421))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2041^1168 \\pmod{2060}$.", + "Output Answer": [ + "$461$" + ], + "Output Program": [ + "print(pow(2041, 1168, 2060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{778,130,333\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 778, 130, 333\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1243x \\equiv 1 \\pmod{1882}$.", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "print(pow(1243, -1, 1882))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 15 \\pmod{11}$", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (15, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 18), (15, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 18), (15, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16635}{758}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{279021481}-16635}{1516}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16635/758)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6032}{3157}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19062905}-3016}{3157}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6032/3157)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{372,545\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 372, 545\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 18 \\pmod{10}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 3), (18, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 3), (18, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 3), (18, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1389^2499 \\pmod{2088}$.", + "Output Answer": [ + "$1989$" + ], + "Output Program": [ + "print(pow(1389, 2499, 2088))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29417 \\pmod{60}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(29417 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $385^m \\equiv 1 \\pmod{618}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(385, 618))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38155 \\pmod{31}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(38155 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1563)$.", + "Output Answer": [ + "$1040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1563))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-5229$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5229 % -21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-19140$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-19140 % 20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $287$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(287 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1391x \\equiv 1 \\pmod{1695}$.", + "Output Answer": [ + "$1511$" + ], + "Output Program": [ + "print(pow(1391, -1, 1695))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $855^1841 \\pmod{1661}$.", + "Output Answer": [ + "$327$" + ], + "Output Program": [ + "print(pow(855, 1841, 1661))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $104^m \\equiv 1 \\pmod{371}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(104, 371))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $9571$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9571 % -17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{4}$\n$x \\equiv 0 \\pmod{2}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 4), (0, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 4), (0, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{146}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(pow(79, -1, 146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{15}$\n$x \\equiv 3 \\pmod{14}$\n$x \\equiv 17 \\pmod{13}$\n$x \\equiv 9 \\pmod{3}$", + "Output Answer": [ + "$1473$" + ], + "Output Program": [ + "constraints = (18, 15), (3, 14), (17, 13), (9, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 15), (3, 14), (17, 13), (9, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3584}{1509}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5488345}-1792}{1509}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3584/1509)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48260)$.", + "Output Answer": [ + "$18144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48260))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $837^m \\equiv 1 \\pmod{901}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(837, 901))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94729 \\pmod{60}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(94729 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11698}{14215}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{236277026}-5849}{14215}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11698/14215)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n19681", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(19681))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{420}{191}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{191} \\left(\\sqrt{80581}-210\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(420/191)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $33^m \\equiv 1 \\pmod{932}$.", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(33, 932))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{405,-526,-380\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 405, -526, -380\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1239x \\equiv 1 \\pmod{1549}$.", + "Output Answer": [ + "$1544$" + ], + "Output Program": [ + "print(pow(1239, -1, 1549))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1811$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1811 % -49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41269$.", + "Output Answer": [ + "$\\{2,11,13,14,17,24,30,32,33,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41269):\n if len(roots) == 10: break\n if gcd(a, 41269) == 1 and is_primitive_root(a, 41269):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-896,407,58\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -896, 407, 58\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $561$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(561 % 9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-151,-630,931\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -151, -630, 931\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n32009", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(32009))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1372^2327 \\pmod{2448}$.", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "print(pow(1372, 2327, 2448))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $95436$.", + "Output Answer": [ + "$2^2\\cdot 3^2\\cdot 11^1\\cdot 241^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(95436))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1001^2392 \\pmod{2109}$.", + "Output Answer": [ + "$712$" + ], + "Output Program": [ + "print(pow(1001, 2392, 2109))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{11}$\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 2 \\pmod{16}$", + "Output Answer": [ + "$866$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 11), (19, 7), (2, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 11), (19, 7), (2, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 11), (19, 7), (2, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7284$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-7284 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1872^1183 \\pmod{2305}$.", + "Output Answer": [ + "$2278$" + ], + "Output Program": [ + "print(pow(1872, 1183, 2305))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $555^2307 \\pmod{860}$.", + "Output Answer": [ + "$475$" + ], + "Output Program": [ + "print(pow(555, 2307, 860))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n12377", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2197}{5346}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{119145673}-2197}{10692}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2197/5346)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47607)$.", + "Output Answer": [ + "$27192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47607))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $609$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(609 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20885 \\pmod{50}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(20885 % 50)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $4653$ is divisible by $-47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4653 % -47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{37}{976}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3811673}-37}{1952}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37/976)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8939 \\pmod{76}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(8939 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-448,57,-285\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -448, 57, -285\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1627x \\equiv 1 \\pmod{2415}$.", + "Output Answer": [ + "$1468$" + ], + "Output Program": [ + "print(pow(1627, -1, 2415))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-294,-93\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -294, -93\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $613$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(613 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-35666$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-35666 % -34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2505$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2505 % -15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{661,281,7\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 661, 281, 7\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1746^1472 \\pmod{2868}$.", + "Output Answer": [ + "$1860$" + ], + "Output Program": [ + "print(pow(1746, 1472, 2868))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{7}$\n$x \\equiv 16 \\pmod{15}$", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 7), (16, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 7), (16, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 7), (16, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-945,672\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -945, 672\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82441 \\pmod{46}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(82441 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37120 \\pmod{85}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(37120 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1482$ is divisible by $38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1482 % 38 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{235,-537\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 235, -537\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $102110_4$ to base 10.", + "Output Answer": [ + "$1172$" + ], + "Output Program": [ + "n = '102110'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $254^m \\equiv 1 \\pmod{261}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(254, 261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1278^1264 \\pmod{2462}$.", + "Output Answer": [ + "$686$" + ], + "Output Program": [ + "print(pow(1278, 1264, 2462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{171}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(79, -1, 171))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.244$ to base $13$.", + "Output Answer": [ + "$\\text{0.3230b}_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.244\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 13 \\pmod{7}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 4), (13, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 4), (13, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 4), (13, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-995,-665\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -995, -665\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{10}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 10), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 10), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 10), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n77745", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(77745))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2355^2021 \\pmod{2737}$.", + "Output Answer": [ + "$2014$" + ], + "Output Program": [ + "print(pow(2355, 2021, 2737))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{4}$\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 11 \\pmod{17}$", + "Output Answer": [ + "$470$" + ], + "Output Program": [ + "constraints = (6, 4), (5, 15), (11, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 4), (5, 15), (11, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 4), (5, 15), (11, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $77^m \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(77, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44195 \\pmod{5}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(44195 % 5)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $239x \\equiv 1 \\pmod{249}$.", + "Output Answer": [ + "$224$" + ], + "Output Program": [ + "print(pow(239, -1, 249))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8788}{3355}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{30563261}-4394}{3355}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8788/3355)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39813 \\pmod{73}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(39813 % 73)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23927 \\pmod{99}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(23927 % 99)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26464 \\pmod{61}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(26464 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n47821", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(47821))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{645,593,-932\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 645, 593, -932\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{569,124,871\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 569, 124, 871\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{21987}{19121}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1945878733}-21987}{38242}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21987/19121)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $328^m \\equiv 1 \\pmod{375}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(328, 375))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8936)$.", + "Output Answer": [ + "$4464$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71153", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71153))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-87,337\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -87, 337\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $627^2083 \\pmod{1491}$.", + "Output Answer": [ + "$837$" + ], + "Output Program": [ + "print(pow(627, 2083, 1491))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $980^1794 \\pmod{2976}$.", + "Output Answer": [ + "$1504$" + ], + "Output Program": [ + "print(pow(980, 1794, 2976))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4}{65}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{65} \\left(\\sqrt{4229}-2\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4/65)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39984)$.", + "Output Answer": [ + "$10752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39984))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $877x \\equiv 1 \\pmod{2328}$.", + "Output Answer": [ + "$1237$" + ], + "Output Program": [ + "print(pow(877, -1, 2328))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{18}$\n$x \\equiv 20 \\pmod{10}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 18), (20, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 18), (20, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26843 \\pmod{98}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(26843 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11924}{17791}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{14082605}-5962}{17791}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11924/17791)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $197x \\equiv 1 \\pmod{674}$.", + "Output Answer": [ + "$609$" + ], + "Output Program": [ + "print(pow(197, -1, 674))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6538}{6961}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{59141882}-3269}{6961}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6538/6961)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $337^1180 \\pmod{629}$.", + "Output Answer": [ + "$514$" + ], + "Output Program": [ + "print(pow(337, 1180, 629))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{525,-111\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = 525, -111\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44843", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44843))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40065 \\pmod{51}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(40065 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-697$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-697 % 18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-593,-867,287\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -593, -867, 287\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n25719", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(25719))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $895$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(895 % -44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{8}$\n$x \\equiv 6 \\pmod{11}$", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 8), (6, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 8), (6, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 8), (6, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $641^m \\equiv 1 \\pmod{751}$.", + "Output Answer": [ + "$375$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(641, 751))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-766,388\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -766, 388\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $29x \\equiv 1 \\pmod{903}$.", + "Output Answer": [ + "$218$" + ], + "Output Program": [ + "print(pow(29, -1, 903))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{766}{4395}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19462714}-383}{4395}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(766/4395)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3109 \\pmod{97}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(3109 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1426^475 \\pmod{2758}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "print(pow(1426, 475, 2758))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $55230$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(55230 % -35 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22833)$.", + "Output Answer": [ + "$14616$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22833))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $294^m \\equiv 1 \\pmod{607}$.", + "Output Answer": [ + "$202$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(294, 607))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1031_6$ to base 10.", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "n = '1031'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $225^m \\equiv 1 \\pmod{478}$.", + "Output Answer": [ + "$119$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(225, 478))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $250x \\equiv 1 \\pmod{347}$.", + "Output Answer": [ + "$93$" + ], + "Output Program": [ + "print(pow(250, -1, 347))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57413 \\pmod{14}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(57413 % 14)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5526$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5526 % 18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $106^1586 \\pmod{1494}$.", + "Output Answer": [ + "$1120$" + ], + "Output Program": [ + "print(pow(106, 1586, 1494))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80857 \\pmod{8}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(80857 % 8)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{211,-504,816\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 211, -504, 816\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $584^1936 \\pmod{1371}$.", + "Output Answer": [ + "$133$" + ], + "Output Program": [ + "print(pow(584, 1936, 1371))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28333)$.", + "Output Answer": [ + "$27328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28333))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2726$ to base $21$.", + "Output Answer": [ + "$\\text{63h}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2726\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 14 \\pmod{19}$", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "constraints = (1, 11), (14, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 11), (14, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 11), (14, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60467 \\pmod{20}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(60467 % 20)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-470$ is divisible by $-5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-470 % -5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26267)$.", + "Output Answer": [ + "$26266$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26267))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $428$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(428 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11734 \\pmod{81}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "print(11734 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $150_{27}$ to base 10.", + "Output Answer": [ + "$864$" + ], + "Output Program": [ + "n = '150'.strip('.')\nbase = 27\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41710)$.", + "Output Answer": [ + "$16128$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41710))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12129)$.", + "Output Answer": [ + "$7440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12129))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n55313", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55313))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $89x \\equiv 1 \\pmod{168}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(89, -1, 168))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{12}$\n$x \\equiv 2 \\pmod{13}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "constraints = (8, 12), (2, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 12), (2, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 12), (2, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $864^2155 \\pmod{1259}$.", + "Output Answer": [ + "$665$" + ], + "Output Program": [ + "print(pow(864, 2155, 1259))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $369x \\equiv 1 \\pmod{602}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(pow(369, -1, 602))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18268)$.", + "Output Answer": [ + "$9132$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18268))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $481^m \\equiv 1 \\pmod{880}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(481, 880))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $533^m \\equiv 1 \\pmod{894}$.", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(533, 894))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{3,-2,-5\\}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "import math\n\nvalues = 3, -2, -5\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $31542$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(31542 % -42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1163x \\equiv 1 \\pmod{1518}$.", + "Output Answer": [ + "$821$" + ], + "Output Program": [ + "print(pow(1163, -1, 1518))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94707 \\pmod{100}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(94707 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $632x \\equiv 1 \\pmod{1707}$.", + "Output Answer": [ + "$1418$" + ], + "Output Program": [ + "print(pow(632, -1, 1707))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $13646$.", + "Output Answer": [ + "$\\{3,13,17,29,35,37,41,45,47,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(13646):\n if len(roots) == 10: break\n if gcd(a, 13646) == 1 and is_primitive_root(a, 13646):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{716,-130\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 716, -130\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{437,777,-574\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 437, 777, -574\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.57$ to base $5$.", + "Output Answer": [ + "$0.241111111_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.57\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $221x \\equiv 1 \\pmod{692}$.", + "Output Answer": [ + "$501$" + ], + "Output Program": [ + "print(pow(221, -1, 692))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66389 \\pmod{89}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "print(66389 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5024}{5883}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{40919833}-2512}{5883}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5024/5883)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{701}{7036}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{198512585}-701}{14072}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(701/7036)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4705 \\pmod{91}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(4705 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-252,-188\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -252, -188\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $413x \\equiv 1 \\pmod{1070}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(pow(413, -1, 1070))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-462,617\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -462, 617\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $113x \\equiv 1 \\pmod{145}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(pow(113, -1, 145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $3320_7$ to base 10.", + "Output Answer": [ + "$1190$" + ], + "Output Program": [ + "n = '3320'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $21419$.", + "Output Answer": [ + "$\\{2,6,8,10,13,14,18,19,22,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(21419):\n if len(roots) == 10: break\n if gcd(a, 21419) == 1 and is_primitive_root(a, 21419):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n12823", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12823))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{12}$\n$x \\equiv 3 \\pmod{16}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 12), (3, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 12), (3, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{12}$\n$x \\equiv 4 \\pmod{20}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 12), (4, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 12), (4, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 1 \\pmod{13}$\n$x \\equiv 7 \\pmod{19}$\n$x \\equiv 9 \\pmod{4}$", + "Output Answer": [ + "$6657$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 7), (1, 13), (7, 19), (9, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 7), (1, 13), (7, 19), (9, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 7), (1, 13), (7, 19), (9, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $66^m \\equiv 1 \\pmod{377}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(66, 377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $305^m \\equiv 1 \\pmod{552}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(305, 552))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $799$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(799 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1421x \\equiv 1 \\pmod{1675}$.", + "Output Answer": [ + "$1431$" + ], + "Output Program": [ + "print(pow(1421, -1, 1675))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23537)$.", + "Output Answer": [ + "$23536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23537))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $283^m \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(283, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1217^664 \\pmod{1759}$.", + "Output Answer": [ + "$812$" + ], + "Output Program": [ + "print(pow(1217, 664, 1759))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43500)$.", + "Output Answer": [ + "$11200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{707,36,-704\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 707, 36, -704\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $50354$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(50354 % 34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27568}{4983}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{214828945}-13784}{4983}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27568/4983)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-226$ is divisible by $26$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-226 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{781,725,996\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 781, 725, 996\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14305}{15024}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1107515329}-14305}{30048}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14305/15024)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{594,25\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 594, 25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-625,-668\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -625, -668\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1999^1761 \\pmod{2926}$.", + "Output Answer": [ + "$239$" + ], + "Output Program": [ + "print(pow(1999, 1761, 2926))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13447}{17898}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{58487017}-13447}{35796}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13447/17898)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.6$ to base $3$.", + "Output Answer": [ + "$0.1210121012102_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.6\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6599}{9130}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{376974401}-6599}{18260}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6599/9130)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53857$.", + "Output Answer": [ + "$\\{5,7,14,15,20,26,37,39,40,42\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53857):\n if len(roots) == 10: break\n if gcd(a, 53857) == 1 and is_primitive_root(a, 53857):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $671x \\equiv 1 \\pmod{1278}$.", + "Output Answer": [ + "$659$" + ], + "Output Program": [ + "print(pow(671, -1, 1278))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2373^579 \\pmod{2775}$.", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "print(pow(2373, 579, 2775))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{654,649,894\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 654, 649, 894\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53003", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53003))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1723x \\equiv 1 \\pmod{2416}$.", + "Output Answer": [ + "$1907$" + ], + "Output Program": [ + "print(pow(1723, -1, 2416))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75371 \\pmod{59}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(75371 % 59)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 7 \\pmod{16}$", + "Output Answer": [ + "$983$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 9), (4, 11), (7, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 9), (4, 11), (7, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (11, 9), (4, 11), (7, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2065}{6992}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{199816481}-2065}{13984}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2065/6992)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39832 \\pmod{45}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(39832 % 45)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{20}$\n$x \\equiv 9 \\pmod{17}$", + "Output Answer": [ + "$298$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 20), (9, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 20), (9, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 20), (9, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $29463$.", + "Output Answer": [ + "$3^1\\cdot 7^1\\cdot 23^1\\cdot 61^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(29463))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33829 \\pmod{77}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(33829 % 77)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7621}{2753}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{88395677}-7621}{5506}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7621/2753)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19663)$.", + "Output Answer": [ + "$16536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19663))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-259,-19\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -259, -19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6689}{18000}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1340742721}-6689}{36000}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6689/18000)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5196}{6151}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{44584405}-2598}{6151}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5196/6151)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $33619$.", + "Output Answer": [ + "$\\{2,10,12,14,15,18,26,29,32,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(33619):\n if len(roots) == 10: break\n if gcd(a, 33619) == 1 and is_primitive_root(a, 33619):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $46896$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(46896 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $83x \\equiv 1 \\pmod{1888}$.", + "Output Answer": [ + "$91$" + ], + "Output Program": [ + "print(pow(83, -1, 1888))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n59671", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59671))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{56,389,949\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 56, 389, 949\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7418 \\pmod{37}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(7418 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 19 \\pmod{8}$", + "Output Answer": [ + "$403$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 13), (18, 11), (19, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 13), (18, 11), (19, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 13), (18, 11), (19, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $75x \\equiv 1 \\pmod{206}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(75, -1, 206))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $771x \\equiv 1 \\pmod{880}$.", + "Output Answer": [ + "$331$" + ], + "Output Program": [ + "print(pow(771, -1, 880))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $649^m \\equiv 1 \\pmod{665}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(649, 665))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $142^m \\equiv 1 \\pmod{533}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(142, 533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11067$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-11067 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2409^143 \\pmod{2730}$.", + "Output Answer": [ + "$309$" + ], + "Output Program": [ + "print(pow(2409, 143, 2730))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63485 \\pmod{88}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(63485 % 88)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $516^m \\equiv 1 \\pmod{925}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(516, 925))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2412^15 \\pmod{2890}$.", + "Output Answer": [ + "$2728$" + ], + "Output Program": [ + "print(pow(2412, 15, 2890))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 5 \\pmod{19}$", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 10), (5, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 10), (5, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 10), (5, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5569}{21582}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1894144657}-5569}{43164}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5569/21582)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1381^2428 \\pmod{1756}$.", + "Output Answer": [ + "$981$" + ], + "Output Program": [ + "print(pow(1381, 2428, 1756))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 4 \\pmod{4}$", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "constraints = (12, 18), (4, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (4, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $627$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(627 % -9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-577,283,136\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -577, 283, 136\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{12}$\n$x \\equiv 5 \\pmod{19}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "import math\n\nconstraints = (12, 12), (5, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 12), (5, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 12), (5, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{5}$\n$x \\equiv 16 \\pmod{16}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "constraints = (17, 5), (16, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 5), (16, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 5), (16, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{19}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$134$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 19), (13, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 19), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 19), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $823x \\equiv 1 \\pmod{1470}$.", + "Output Answer": [ + "$877$" + ], + "Output Program": [ + "print(pow(823, -1, 1470))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1626^1780 \\pmod{2116}$.", + "Output Answer": [ + "$836$" + ], + "Output Program": [ + "print(pow(1626, 1780, 2116))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $327^m \\equiv 1 \\pmod{458}$.", + "Output Answer": [ + "$228$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(327, 458))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13973}{1067}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{199798685}-13973}{2134}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13973/1067)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47572)$.", + "Output Answer": [ + "$20376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47572))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $39517$.", + "Output Answer": [ + "$43^1\\cdot 919^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(39517))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 0 \\pmod{18}$\n$x \\equiv 19 \\pmod{19}$", + "Output Answer": [ + "$684$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 5), (0, 18), (19, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 5), (0, 18), (19, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 5), (0, 18), (19, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73238 \\pmod{92}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(73238 % 92)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 3 \\pmod{14}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "constraints = (7, 8), (3, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 8), (3, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $322^1844 \\pmod{542}$.", + "Output Answer": [ + "$212$" + ], + "Output Program": [ + "print(pow(322, 1844, 542))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $748^1052 \\pmod{1234}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(pow(748, 1052, 1234))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37461 \\pmod{94}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(37461 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $97^m \\equiv 1 \\pmod{473}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(97, 473))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $57334$.", + "Output Answer": [ + "$2^1\\cdot 109^1\\cdot 263^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(57334))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1841^1921 \\pmod{2313}$.", + "Output Answer": [ + "$1841$" + ], + "Output Program": [ + "print(pow(1841, 1921, 2313))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2140}{1489}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3362021}-1070}{1489}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2140/1489)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-497,924,-267\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -497, 924, -267\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{8}$\n$x \\equiv 12 \\pmod{5}$\n$x \\equiv 14 \\pmod{7}$", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 8), (12, 5), (14, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 8), (12, 5), (14, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 8), (12, 5), (14, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $551x \\equiv 1 \\pmod{2060}$.", + "Output Answer": [ + "$1731$" + ], + "Output Program": [ + "print(pow(551, -1, 2060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $283x \\equiv 1 \\pmod{616}$.", + "Output Answer": [ + "$579$" + ], + "Output Program": [ + "print(pow(283, -1, 616))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15391 \\pmod{76}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(15391 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3590}{3869}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18191186}-1795}{3869}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3590/3869)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2347$ to base $23$.", + "Output Answer": [ + "$\\text{4a1}_{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2347\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17875 \\pmod{61}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(17875 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $57^2137 \\pmod{944}$.", + "Output Answer": [ + "$441$" + ], + "Output Program": [ + "print(pow(57, 2137, 944))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9340 \\pmod{55}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(9340 % 55)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21173 \\pmod{7}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(21173 % 7)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 12 \\pmod{14}$\n$x \\equiv 14 \\pmod{3}$", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 5), (12, 14), (14, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 5), (12, 14), (14, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 5), (12, 14), (14, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1237x \\equiv 1 \\pmod{1881}$.", + "Output Answer": [ + "$295$" + ], + "Output Program": [ + "print(pow(1237, -1, 1881))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $445^m \\equiv 1 \\pmod{686}$.", + "Output Answer": [ + "$147$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(445, 686))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19034 \\pmod{79}$.", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "print(19034 % 79)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $713^575 \\pmod{2984}$.", + "Output Answer": [ + "$2257$" + ], + "Output Program": [ + "print(pow(713, 575, 2984))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77102 \\pmod{78}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(77102 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $14679$.", + "Output Answer": [ + "$3^2\\cdot 7^1\\cdot 233^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(14679))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $107x \\equiv 1 \\pmod{1333}$.", + "Output Answer": [ + "$299$" + ], + "Output Program": [ + "print(pow(107, -1, 1333))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n82001", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82001))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3007}{4083}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{75725605}-3007}{8166}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3007/4083)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n24887", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24887))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2360^1785 \\pmod{2799}$.", + "Output Answer": [ + "$287$" + ], + "Output Program": [ + "print(pow(2360, 1785, 2799))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 5 \\pmod{12}$", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 11), (5, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (5, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (5, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $369$ to base $7$.", + "Output Answer": [ + "$1035_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 369\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1710$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1710 % 6 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7857)$.", + "Output Answer": [ + "$5184$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7857))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1820$ to base $11$.", + "Output Answer": [ + "$1405_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1820\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{12}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (0, 12), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 12), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1496^1435 \\pmod{1779}$.", + "Output Answer": [ + "$206$" + ], + "Output Program": [ + "print(pow(1496, 1435, 1779))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $181^2190 \\pmod{286}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(181, 2190, 286))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47881 \\pmod{49}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(47881 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1102x \\equiv 1 \\pmod{1607}$.", + "Output Answer": [ + "$821$" + ], + "Output Program": [ + "print(pow(1102, -1, 1607))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 0 \\pmod{18}$\n$x \\equiv 17 \\pmod{7}$", + "Output Answer": [ + "$108$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 2), (0, 18), (17, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 2), (0, 18), (17, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n67889", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(67889))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{12}$\n$x \\equiv 3 \\pmod{19}$\n$x \\equiv 5 \\pmod{5}$", + "Output Answer": [ + "$915$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 12), (3, 19), (5, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 12), (3, 19), (5, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 12), (3, 19), (5, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $498^1979 \\pmod{1702}$.", + "Output Answer": [ + "$986$" + ], + "Output Program": [ + "print(pow(498, 1979, 1702))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $3^m \\equiv 1 \\pmod{314}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(3, 314))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $10322$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(10322 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7829}{6722}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{242034377}-7829}{13444}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7829/6722)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39798)$.", + "Output Answer": [ + "$11880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 12 \\pmod{2}$\n$x \\equiv 3 \\pmod{7}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "constraints = (2, 4), (12, 2), (3, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 4), (12, 2), (3, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21083)$.", + "Output Answer": [ + "$20328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21083))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1463$ to base $34$.", + "Output Answer": [ + "$191_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1463\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $829^1615 \\pmod{870}$.", + "Output Answer": [ + "$679$" + ], + "Output Program": [ + "print(pow(829, 1615, 870))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $281x \\equiv 1 \\pmod{1170}$.", + "Output Answer": [ + "$941$" + ], + "Output Program": [ + "print(pow(281, -1, 1170))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{83,-128\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 83, -128\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20952 \\pmod{92}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(20952 % 92)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-16,140\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -16, 140\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3762}{4339}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{22365082}-1881}{4339}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3762/4339)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{936,-299\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 936, -299\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10234}{17419}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{13184210}-5117}{17419}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10234/17419)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1150^63 \\pmod{2257}$.", + "Output Answer": [ + "$369$" + ], + "Output Program": [ + "print(pow(1150, 63, 2257))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1802}{413}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{413} \\left(\\sqrt{982370}-901\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1802/413)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $262x \\equiv 1 \\pmod{417}$.", + "Output Answer": [ + "$304$" + ], + "Output Program": [ + "print(pow(262, -1, 417))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $121^m \\equiv 1 \\pmod{458}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(121, 458))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36164)$.", + "Output Answer": [ + "$18080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36164))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(203)$.", + "Output Answer": [ + "$168$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(203))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{5}$\n$x \\equiv 0 \\pmod{19}$\n$x \\equiv 18 \\pmod{8}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$11818$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 5), (0, 19), (18, 8), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (3, 5), (0, 19), (18, 8), (3, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 5), (0, 19), (18, 8), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69295 \\pmod{57}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(69295 % 57)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $441_{21}$ to base 10.", + "Output Answer": [ + "$1849$" + ], + "Output Program": [ + "n = '441'.strip('.')\nbase = 21\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $8^m \\equiv 1 \\pmod{165}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(8, 165))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n5295", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $975x \\equiv 1 \\pmod{2194}$.", + "Output Answer": [ + "$2185$" + ], + "Output Program": [ + "print(pow(975, -1, 2194))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{189,36,44\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 189, 36, 44\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 20 \\pmod{9}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 5), (20, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 5), (20, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 5), (20, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17735 \\pmod{60}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(17735 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-9,127\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -9, 127\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $700^1157 \\pmod{2724}$.", + "Output Answer": [ + "$1936$" + ], + "Output Program": [ + "print(pow(700, 1157, 2724))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{569}{181}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{362} \\left(\\sqrt{454805}-569\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(569/181)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-334,707\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -334, 707\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44509", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44509))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1156$ to base $22$.", + "Output Answer": [ + "$\\text{28c}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1156\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $2^m \\equiv 1 \\pmod{247}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(2, 247))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-623$ is divisible by $-13$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-623 % -13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-39773$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-39773 % -31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4494)$.", + "Output Answer": [ + "$1272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4494))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{474,971\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 474, 971\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $527$ to base $36$.", + "Output Answer": [ + "$\\text{en}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 527\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60042 \\pmod{26}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(60042 % 26)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n65883", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65883))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $67320$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(67320 % -44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-504,517\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -504, 517\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{250}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 250))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $317^m \\equiv 1 \\pmod{519}$.", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(317, 519))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-304,-715\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -304, -715\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10442 \\pmod{9}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(10442 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44946)$.", + "Output Answer": [ + "$13560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44946))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2404$ to base $7$.", + "Output Answer": [ + "$10003_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2404\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 17 \\pmod{15}$", + "Output Answer": [ + "$3122$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 2), (11, 17), (14, 7), (17, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 2), (11, 17), (14, 7), (17, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (0, 2), (11, 17), (14, 7), (17, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19126)$.", + "Output Answer": [ + "$9360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19126))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n63803", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63803))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1387$ to base $22$.", + "Output Answer": [ + "$\\text{2j1}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1387\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=8$ $6$-gonal number.\n", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "n = 8\nk = 6\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2430^139 \\pmod{3000}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(2430, 139, 3000))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1877}{21180}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1797892729}-1877}{42360}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1877/21180)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{349,-675\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 349, -675\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{1000,-676\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 1000, -676\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67745 \\pmod{23}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(67745 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{3}$\n$x \\equiv 1 \\pmod{3}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 3), (1, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 3), (1, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{28250}{10121}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{301950266}-14125}{10121}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(28250/10121)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $527^m \\equiv 1 \\pmod{841}$.", + "Output Answer": [ + "$406$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(527, 841))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-984,171\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -984, 171\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3866}{2111}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8192810}-1933}{2111}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3866/2111)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n26647", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26647))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1503x \\equiv 1 \\pmod{2146}$.", + "Output Answer": [ + "$1879$" + ], + "Output Program": [ + "print(pow(1503, -1, 2146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8734)$.", + "Output Answer": [ + "$3960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8734))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{222,33\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 222, 33\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2324^872 \\pmod{2383}$.", + "Output Answer": [ + "$1916$" + ], + "Output Program": [ + "print(pow(2324, 872, 2383))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2304^946 \\pmod{2663}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(pow(2304, 946, 2663))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $27046$.", + "Output Answer": [ + "$2^1\\cdot 13523^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(27046))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1981}{14674}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{865229465}-1981}{29348}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1981/14674)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $963x \\equiv 1 \\pmod{2122}$.", + "Output Answer": [ + "$249$" + ], + "Output Program": [ + "print(pow(963, -1, 2122))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{19}$\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 20 \\pmod{4}$\n$x \\equiv 20 \\pmod{14}$", + "Output Answer": [ + "$2344$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 19), (4, 13), (20, 4), (20, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 19), (4, 13), (20, 4), (20, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2690}{2843}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9891674}-1345}{2843}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2690/2843)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1040)$.", + "Output Answer": [ + "$384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1040))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3111}{3908}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{70768177}-3111}{7816}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3111/3908)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 18 \\pmod{19}$", + "Output Answer": [ + "$208$" + ], + "Output Program": [ + "constraints = (4, 17), (18, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 17), (18, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 17), (18, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2095}{3678}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{58499761}-2095}{7356}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2095/3678)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 1 \\pmod{2}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "constraints = (11, 9), (1, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 9), (1, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 9), (1, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n4987", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4987))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14033}{24045}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2509573189}-14033}{48090}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14033/24045)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n82885", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82885))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n30011", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(30011))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{2}$\n$x \\equiv 9 \\pmod{3}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 2), (9, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 2), (9, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 2), (9, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $51559$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(51559 % 47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7429$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7429 % -17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $412x \\equiv 1 \\pmod{2361}$.", + "Output Answer": [ + "$1255$" + ], + "Output Program": [ + "print(pow(412, -1, 2361))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{7}$\n$x \\equiv 19 \\pmod{16}$", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 7), (19, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 7), (19, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 7), (19, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5960}{14027}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{205637129}-2980}{14027}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5960/14027)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{509}{516}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1324105}-509}{1032}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(509/516)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{843}{854}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3627913}-843}{1708}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(843/854)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-388,209,222\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -388, 209, 222\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-701,-852,185\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -701, -852, 185\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.76$ to base $23$.", + "Output Answer": [ + "$\\text{0.hb0l}_{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.76\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $168x \\equiv 1 \\pmod{473}$.", + "Output Answer": [ + "$290$" + ], + "Output Program": [ + "print(pow(168, -1, 473))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1181^1723 \\pmod{1852}$.", + "Output Answer": [ + "$1669$" + ], + "Output Program": [ + "print(pow(1181, 1723, 1852))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17713}{8715}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{617555269}-17713}{17430}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17713/8715)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 13 \\pmod{15}$\n$x \\equiv 16 \\pmod{19}$", + "Output Answer": [ + "$32848$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (0, 16), (13, 15), (16, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 11), (0, 16), (13, 15), (16, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 11), (0, 16), (13, 15), (16, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{443}{1305}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7008349}-443}{2610}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(443/1305)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{177}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 177))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{690}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 690))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1312}{1081}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1598897}-656}{1081}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1312/1081)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90954 \\pmod{25}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(90954 % 25)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-801,896\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -801, 896\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{866,-179\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 866, -179\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "constraints = (17, 3), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 3), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 3), (13, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{18}$\n$x \\equiv 12 \\pmod{19}$", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 18), (12, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 18), (12, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 18), (12, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70026 \\pmod{61}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(70026 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32471 \\pmod{14}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(32471 % 14)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38188 \\pmod{91}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(38188 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-629,-294\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -629, -294\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $789^m \\equiv 1 \\pmod{929}$.", + "Output Answer": [ + "$928$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(789, 929))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55567 \\pmod{58}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(55567 % 58)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $555^m \\equiv 1 \\pmod{772}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(555, 772))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{385,69\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 385, 69\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $837^2241 \\pmod{2969}$.", + "Output Answer": [ + "$1369$" + ], + "Output Program": [ + "print(pow(837, 2241, 2969))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $765^m \\equiv 1 \\pmod{973}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(765, 973))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8483)$.", + "Output Answer": [ + "$7968$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $196^2499 \\pmod{579}$.", + "Output Answer": [ + "$220$" + ], + "Output Program": [ + "print(pow(196, 2499, 579))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $44101$.", + "Output Answer": [ + "$\\{6,10,13,29,40,42,50,51,52,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(44101):\n if len(roots) == 10: break\n if gcd(a, 44101) == 1 and is_primitive_root(a, 44101):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $648$ to base $32$.", + "Output Answer": [ + "$\\text{k8}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 648\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n77683", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(77683))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2575$ to base $12$.", + "Output Answer": [ + "$\\text{15a7}_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2575\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{14}$\n$x \\equiv 17 \\pmod{14}$\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 14 \\pmod{9}$", + "Output Answer": [ + "$1571$" + ], + "Output Program": [ + "constraints = (17, 14), (17, 14), (7, 17), (14, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 14), (17, 14), (7, 17), (14, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65144 \\pmod{81}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(65144 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $411^2074 \\pmod{1614}$.", + "Output Answer": [ + "$657$" + ], + "Output Program": [ + "print(pow(411, 2074, 1614))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2262$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2262 % 18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32851)$.", + "Output Answer": [ + "$24624$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32851))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $782^717 \\pmod{1764}$.", + "Output Answer": [ + "$188$" + ], + "Output Program": [ + "print(pow(782, 717, 1764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71737 \\pmod{4}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(71737 % 4)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $438$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(438 % -31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1303$ to base $3$.", + "Output Answer": [ + "$1210021_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1303\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $19541$.", + "Output Answer": [ + "$\\{2,8,10,12,13,15,18,21,22,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(19541):\n if len(roots) == 10: break\n if gcd(a, 19541) == 1 and is_primitive_root(a, 19541):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $579^546 \\pmod{1693}$.", + "Output Answer": [ + "$723$" + ], + "Output Program": [ + "print(pow(579, 546, 1693))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n31649", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31649))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76409 \\pmod{78}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(76409 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $82x \\equiv 1 \\pmod{375}$.", + "Output Answer": [ + "$343$" + ], + "Output Program": [ + "print(pow(82, -1, 375))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $909$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(909 % 27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20213)$.", + "Output Answer": [ + "$17920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20213))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1243x \\equiv 1 \\pmod{2496}$.", + "Output Answer": [ + "$1747$" + ], + "Output Program": [ + "print(pow(1243, -1, 2496))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90465 \\pmod{82}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(90465 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $27542$.", + "Output Answer": [ + "$2^1\\cdot 47^1\\cdot 293^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(27542))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16596)$.", + "Output Answer": [ + "$5520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16596))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{19}$\n$x \\equiv 13 \\pmod{17}$\n$x \\equiv 3 \\pmod{16}$", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 19), (13, 17), (3, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 19), (13, 17), (3, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 19), (13, 17), (3, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2^97 \\pmod{2145}$.", + "Output Answer": [ + "$392$" + ], + "Output Program": [ + "print(pow(2, 97, 2145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1751}{6978}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{197835937}-1751}{13956}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1751/6978)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{23603}{67}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{134} \\left(\\sqrt{557119565}-23603\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23603/67)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1484$ is divisible by $41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1484 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2423^1618 \\pmod{2758}$.", + "Output Answer": [ + "$2423$" + ], + "Output Program": [ + "print(pow(2423, 1618, 2758))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14619)$.", + "Output Answer": [ + "$8840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82055 \\pmod{47}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(82055 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $257^m \\equiv 1 \\pmod{423}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(257, 423))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-735,-253\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -735, -253\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{555,-946,809\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 555, -946, 809\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15121)$.", + "Output Answer": [ + "$15120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $407x \\equiv 1 \\pmod{762}$.", + "Output Answer": [ + "$425$" + ], + "Output Program": [ + "print(pow(407, -1, 762))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{29529}{20780}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{29 \\sqrt{3090601}-29529}{41560}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29529/20780)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{45,-311,-76\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 45, -311, -76\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-5,2,-4,-3\\}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "import math\n\nvalues = -5, 2, -4, -3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38030)$.", + "Output Answer": [ + "$15208$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38030))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n63331", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63331))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41243)$.", + "Output Answer": [ + "$41242$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41243))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{935,933\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 935, 933\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29603 \\pmod{21}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(29603 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79031 \\pmod{11}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(79031 % 11)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $600^1965 \\pmod{1893}$.", + "Output Answer": [ + "$924$" + ], + "Output Program": [ + "print(pow(600, 1965, 1893))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 7 \\pmod{20}$", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "constraints = (14, 3), (7, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (7, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 3), (7, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $185x \\equiv 1 \\pmod{852}$.", + "Output Answer": [ + "$677$" + ], + "Output Program": [ + "print(pow(185, -1, 852))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38129 \\pmod{9}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(38129 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n14813", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(14813))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 11 \\pmod{6}$\n$x \\equiv 14 \\pmod{3}$", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "constraints = (2, 17), (11, 6), (14, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 17), (11, 6), (14, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62620 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(62620 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $331^1628 \\pmod{1736}$.", + "Output Answer": [ + "$417$" + ], + "Output Program": [ + "print(pow(331, 1628, 1736))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{5}$\n$x \\equiv 5 \\pmod{8}$", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 5), (5, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 5), (5, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 5), (5, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{130,164,-910\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 130, 164, -910\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24223$.", + "Output Answer": [ + "$\\{3,5,10,11,12,19,22,24,29,35\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24223):\n if len(roots) == 10: break\n if gcd(a, 24223) == 1 and is_primitive_root(a, 24223):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $12734$.", + "Output Answer": [ + "$\\{3,5,7,39,57,61,63,65,71,83\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(12734):\n if len(roots) == 10: break\n if gcd(a, 12734) == 1 and is_primitive_root(a, 12734):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $379x \\equiv 1 \\pmod{423}$.", + "Output Answer": [ + "$298$" + ], + "Output Program": [ + "print(pow(379, -1, 423))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4220)$.", + "Output Answer": [ + "$1680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4220))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{15}$\n$x \\equiv 8 \\pmod{5}$\n$x \\equiv 0 \\pmod{7}$", + "Output Answer": [ + "$98$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 15), (8, 5), (0, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 15), (8, 5), (0, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14578)$.", + "Output Answer": [ + "$7056$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14578))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18683}{17363}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{9200885}-18683}{34726}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18683/17363)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 2 \\pmod{13}$", + "Output Answer": [ + "$132$" + ], + "Output Program": [ + "constraints = (4, 16), (2, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 16), (2, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 16), (2, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1990}{1361}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2842346}-995}{1361}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1990/1361)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $9x \\equiv 1 \\pmod{16}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(pow(9, -1, 16))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{371}{2010}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{16298041}-371}{4020}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(371/2010)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n46603", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(46603))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{19991}{21084}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2177780305}-19991}{42168}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19991/21084)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n22095", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(22095))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 9 \\pmod{14}$", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 11), (9, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 11), (9, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 11), (9, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{203,-334,225\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 203, -334, 225\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17353)$.", + "Output Answer": [ + "$14256$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17353))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1053x \\equiv 1 \\pmod{2090}$.", + "Output Answer": [ + "$1437$" + ], + "Output Program": [ + "print(pow(1053, -1, 2090))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{8}$\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 11 \\pmod{19}$", + "Output Answer": [ + "$163$" + ], + "Output Program": [ + "constraints = (11, 8), (7, 3), (11, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 8), (7, 3), (11, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 8), (7, 3), (11, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{15}$\n$x \\equiv 9 \\pmod{11}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (9, 15), (9, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 15), (9, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 15), (9, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 4 \\pmod{9}$\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 10 \\pmod{13}$", + "Output Answer": [ + "$2974$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 11), (4, 9), (16, 17), (10, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 11), (4, 9), (16, 17), (10, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 11), (4, 9), (16, 17), (10, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71516 \\pmod{26}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(71516 % 26)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $9422$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9422 % -14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $397^m \\equiv 1 \\pmod{458}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(397, 458))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $761x \\equiv 1 \\pmod{891}$.", + "Output Answer": [ + "$281$" + ], + "Output Program": [ + "print(pow(761, -1, 891))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90291 \\pmod{85}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(90291 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $12090$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(12090 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{153}{538}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1181185}-153}{1076}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(153/538)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{3}$\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 12 \\pmod{10}$", + "Output Answer": [ + "$262$" + ], + "Output Program": [ + "constraints = (13, 3), (7, 17), (12, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 3), (7, 17), (12, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 3), (7, 17), (12, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 7 \\pmod{4}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "constraints = (17, 3), (7, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 3), (7, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 3), (7, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62708 \\pmod{27}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(62708 % 27)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=3$ $8$-gonal number.\n", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "n = 3\nk = 8\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n62297", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(62297))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2198^511 \\pmod{2686}$.", + "Output Answer": [ + "$2234$" + ], + "Output Program": [ + "print(pow(2198, 511, 2686))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{235}{1452}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8488441}-235}{2904}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(235/1452)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56014 \\pmod{46}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(56014 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{86,-546,51\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 86, -546, 51\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $607x \\equiv 1 \\pmod{950}$.", + "Output Answer": [ + "$493$" + ], + "Output Program": [ + "print(pow(607, -1, 950))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $352^m \\equiv 1 \\pmod{525}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(352, 525))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{426,-836,43\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 426, -836, 43\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2902$ to base $21$.", + "Output Answer": [ + "$\\text{6c4}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2902\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3817)$.", + "Output Answer": [ + "$3460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3817))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31282 \\pmod{33}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(31282 % 33)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-839,379\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -839, 379\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-252,-558\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -252, -558\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $67450$.", + "Output Answer": [ + "$2^1\\cdot 5^2\\cdot 19^1\\cdot 71^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(67450))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $415^m \\equiv 1 \\pmod{441}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(415, 441))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $372x \\equiv 1 \\pmod{1055}$.", + "Output Answer": [ + "$173$" + ], + "Output Program": [ + "print(pow(372, -1, 1055))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4543}{6694}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{199877393}-4543}{13388}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4543/6694)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7065 \\pmod{65}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(7065 % 65)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n1657", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1657))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50979 \\pmod{89}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(50979 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-789,-879\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -789, -879\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39794)$.", + "Output Answer": [ + "$19600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39794))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{8}$\n$x \\equiv 20 \\pmod{2}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 8), (20, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 8), (20, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.2103331331_4$ to base 10.", + "Output Answer": [ + "$0.578$" + ], + "Output Program": [ + "n = '0.2103331331'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n64891", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64891))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2045$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2045 % -46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92576 \\pmod{34}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(92576 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{269,-558\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 269, -558\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{13}$\n$x \\equiv 1 \\pmod{15}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 13), (1, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 13), (1, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 13), (1, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-60,-699,550\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -60, -699, 550\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-33077$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-33077 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33461)$.", + "Output Answer": [ + "$33460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33461))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $251^m \\equiv 1 \\pmod{627}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(251, 627))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-961,349\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -961, 349\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3023}{4386}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{86086513}-3023}{8772}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3023/4386)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11070$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-11070 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{563,226,159\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 563, 226, 159\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24953$.", + "Output Answer": [ + "$\\{3,5,6,7,10,12,13,14,17,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24953):\n if len(roots) == 10: break\n if gcd(a, 24953) == 1 and is_primitive_root(a, 24953):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1937}{6894}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{193860913}-1937}{13788}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1937/6894)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80066 \\pmod{18}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(80066 % 18)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $173x \\equiv 1 \\pmod{656}$.", + "Output Answer": [ + "$565$" + ], + "Output Program": [ + "print(pow(173, -1, 656))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-10584$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10584 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $744$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(744 % -31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44940 \\pmod{50}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(44940 % 50)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{742}{2453}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{246194}-371}{2453}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(742/2453)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-832,-416\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -832, -416\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7722$ is divisible by $36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-7722 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10137}{6130}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{253066369}-10137}{12260}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10137/6130)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $180^m \\equiv 1 \\pmod{667}$.", + "Output Answer": [ + "$154$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(180, 667))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $521$ is divisible by $21$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(521 % 21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33256)$.", + "Output Answer": [ + "$16624$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33256))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8778)$.", + "Output Answer": [ + "$2160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8778))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24793$.", + "Output Answer": [ + "$\\{5,7,13,15,17,20,21,22,23,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24793):\n if len(roots) == 10: break\n if gcd(a, 24793) == 1 and is_primitive_root(a, 24793):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $516_{14}$ to base 10.", + "Output Answer": [ + "$1000$" + ], + "Output Program": [ + "n = '516'.strip('.')\nbase = 14\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73350 \\pmod{100}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(73350 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1910^1858 \\pmod{2059}$.", + "Output Answer": [ + "$864$" + ], + "Output Program": [ + "print(pow(1910, 1858, 2059))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39956)$.", + "Output Answer": [ + "$17112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39956))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-46527$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-46527 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26723)$.", + "Output Answer": [ + "$26722$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26723))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $59663$.", + "Output Answer": [ + "$\\{5,7,10,13,14,15,20,21,23,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(59663):\n if len(roots) == 10: break\n if gcd(a, 59663) == 1 and is_primitive_root(a, 59663):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20703 \\pmod{100}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(20703 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-183,-605,165\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -183, -605, 165\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1693^1517 \\pmod{2363}$.", + "Output Answer": [ + "$1201$" + ], + "Output Program": [ + "print(pow(1693, 1517, 2363))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $3615_8$ to base 10.", + "Output Answer": [ + "$1933$" + ], + "Output Program": [ + "n = '3615'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $85x \\equiv 1 \\pmod{1754}$.", + "Output Answer": [ + "$227$" + ], + "Output Program": [ + "print(pow(85, -1, 1754))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48885)$.", + "Output Answer": [ + "$26064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48885))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.52$ to base $29$.", + "Output Answer": [ + "$\\text{0.f298}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.52\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(145)$.", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88346 \\pmod{97}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "print(88346 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $62332$.", + "Output Answer": [ + "$2^2\\cdot 15583^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(62332))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25907)$.", + "Output Answer": [ + "$22200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25907))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $25882$.", + "Output Answer": [ + "$\\{3,7,15,19,23,27,41,63,65,75\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(25882):\n if len(roots) == 10: break\n if gcd(a, 25882) == 1 and is_primitive_root(a, 25882):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{46386}{35765}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1817050474}-23193}{35765}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(46386/35765)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{355,778,968\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 355, 778, 968\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{119}{1070}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4593761}-119}{2140}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(119/1070)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40716)$.", + "Output Answer": [ + "$12096$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40716))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $988^907 \\pmod{2771}$.", + "Output Answer": [ + "$773$" + ], + "Output Program": [ + "print(pow(988, 907, 2771))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34981)$.", + "Output Answer": [ + "$34980$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $42x \\equiv 1 \\pmod{79}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(pow(42, -1, 79))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4615}{30772}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3808962161}-4615}{61544}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4615/30772)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $594$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(594 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{23162}{19309}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{506957042}-11581}{19309}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23162/19309)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 20 \\pmod{2}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (4, 3), (20, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 7), (4, 3), (20, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 7), (4, 3), (20, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $3481$.", + "Output Answer": [ + "$\\{2,6,8,10,11,13,14,18,23,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(3481):\n if len(roots) == 10: break\n if gcd(a, 3481) == 1 and is_primitive_root(a, 3481):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5617}{31314}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3953817073}-5617}{62628}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5617/31314)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35255)$.", + "Output Answer": [ + "$25600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35255))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1628^1524 \\pmod{2433}$.", + "Output Answer": [ + "$1390$" + ], + "Output Program": [ + "print(pow(1628, 1524, 2433))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $7163$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7163 % -19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.77$ to base $4$.", + "Output Answer": [ + "$0.301101323_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.77\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1605}{1244}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8766169}-1605}{2488}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1605/1244)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $607x \\equiv 1 \\pmod{696}$.", + "Output Answer": [ + "$391$" + ], + "Output Program": [ + "print(pow(607, -1, 696))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1911$ to base $8$.", + "Output Answer": [ + "$3567_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1911\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $17x \\equiv 1 \\pmod{333}$.", + "Output Answer": [ + "$98$" + ], + "Output Program": [ + "print(pow(17, -1, 333))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-263$ is divisible by $23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-263 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8025)$.", + "Output Answer": [ + "$4240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8025))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38746)$.", + "Output Answer": [ + "$19372$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38746))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $43331$.", + "Output Answer": [ + "$\\{2,6,8,10,18,19,28,30,34,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(43331):\n if len(roots) == 10: break\n if gcd(a, 43331) == 1 and is_primitive_root(a, 43331):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1661$ to base $16$.", + "Output Answer": [ + "$\\text{67d}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1661\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n43759", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43759))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $85^m \\equiv 1 \\pmod{369}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(85, 369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $284^m \\equiv 1 \\pmod{699}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(284, 699))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11627}{2056}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{152095673}-11627}{4112}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11627/2056)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $545x \\equiv 1 \\pmod{628}$.", + "Output Answer": [ + "$401$" + ], + "Output Program": [ + "print(pow(545, -1, 628))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $61981$.", + "Output Answer": [ + "$\\{7,11,21,23,28,30,33,34,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(61981):\n if len(roots) == 10: break\n if gcd(a, 61981) == 1 and is_primitive_root(a, 61981):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1267x \\equiv 1 \\pmod{2292}$.", + "Output Answer": [ + "$2131$" + ], + "Output Program": [ + "print(pow(1267, -1, 2292))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n78509", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(78509))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{535}{9676}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{374786129}-535}{19352}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(535/9676)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 15 \\pmod{3}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 11), (15, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 11), (15, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 11), (15, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15586 \\pmod{86}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(15586 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n20013", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(20013))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9358)$.", + "Output Answer": [ + "$4678$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9358))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1565x \\equiv 1 \\pmod{2366}$.", + "Output Answer": [ + "$1087$" + ], + "Output Program": [ + "print(pow(1565, -1, 2366))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $104x \\equiv 1 \\pmod{291}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(pow(104, -1, 291))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $301x \\equiv 1 \\pmod{2084}$.", + "Output Answer": [ + "$997$" + ], + "Output Program": [ + "print(pow(301, -1, 2084))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57492 \\pmod{4}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(57492 % 4)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $555x \\equiv 1 \\pmod{574}$.", + "Output Answer": [ + "$151$" + ], + "Output Program": [ + "print(pow(555, -1, 574))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-51576$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-51576 % 42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1784^1647 \\pmod{2450}$.", + "Output Answer": [ + "$2344$" + ], + "Output Program": [ + "print(pow(1784, 1647, 2450))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89581 \\pmod{65}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(89581 % 65)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5510$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5510 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-733,850\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -733, 850\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $151^m \\equiv 1 \\pmod{575}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(151, 575))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55230 \\pmod{96}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(55230 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 839 \\pmod{41}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(839 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4101)$.", + "Output Answer": [ + "$2732$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4101))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 15 \\pmod{5}$", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 3), (1, 7), (15, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 3), (1, 7), (15, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 3), (1, 7), (15, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $43146$.", + "Output Answer": [ + "$2^1\\cdot 3^3\\cdot 17^1\\cdot 47^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(43146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24359$.", + "Output Answer": [ + "$\\{11,19,22,23,33,37,38,43,44,46\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24359):\n if len(roots) == 10: break\n if gcd(a, 24359) == 1 and is_primitive_root(a, 24359):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $57^2355 \\pmod{2414}$.", + "Output Answer": [ + "$2273$" + ], + "Output Program": [ + "print(pow(57, 2355, 2414))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2269}{15705}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{991736461}-2269}{31410}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2269/15705)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{13,30,-960\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 13, 30, -960\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-580,555,574\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -580, 555, 574\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{14}$\n$x \\equiv 15 \\pmod{18}$", + "Output Answer": [ + "$87$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 14), (15, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 14), (15, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1239}{19762}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1563681697}-1239}{39524}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1239/19762)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 20 \\pmod{13}$\n$x \\equiv 2 \\pmod{20}$\n$x \\equiv 16 \\pmod{19}$", + "Output Answer": [ + "$3322$" + ], + "Output Program": [ + "constraints = (10, 8), (20, 13), (2, 20), (16, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 8), (20, 13), (2, 20), (16, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $16034$.", + "Output Answer": [ + "$\\{5,19,41,43,45,51,53,55,59,61\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(16034):\n if len(roots) == 10: break\n if gcd(a, 16034) == 1 and is_primitive_root(a, 16034):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1391$ to base $19$.", + "Output Answer": [ + "$\\text{3g4}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1391\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $90567$.", + "Output Answer": [ + "$3^2\\cdot 29^1\\cdot 347^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(90567))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-136$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-136 % -35 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{149,135,75\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 149, 135, 75\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{619,450,549\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 619, 450, 549\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $324^m \\equiv 1 \\pmod{851}$.", + "Output Answer": [ + "$198$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(324, 851))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2407^59 \\pmod{2857}$.", + "Output Answer": [ + "$2781$" + ], + "Output Program": [ + "print(pow(2407, 59, 2857))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1531^1305 \\pmod{2443}$.", + "Output Answer": [ + "$699$" + ], + "Output Program": [ + "print(pow(1531, 1305, 2443))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72103 \\pmod{96}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(72103 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n50309", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50309))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10979)$.", + "Output Answer": [ + "$10978$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10979))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{191}$.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 191))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1933^1121 \\pmod{2311}$.", + "Output Answer": [ + "$1319$" + ], + "Output Program": [ + "print(pow(1933, 1121, 2311))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38176)$.", + "Output Answer": [ + "$19072$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38176))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $763^m \\equiv 1 \\pmod{790}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(763, 790))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n70349", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70349))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $63375$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(63375 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33897)$.", + "Output Answer": [ + "$22596$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33897))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27727}{27109}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3708378053}-27727}{54218}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27727/27109)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{797}{2192}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19854665}-797}{4384}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(797/2192)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1716^1412 \\pmod{2539}$.", + "Output Answer": [ + "$1812$" + ], + "Output Program": [ + "print(pow(1716, 1412, 2539))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43657)$.", + "Output Answer": [ + "$43216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43657))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $51896$.", + "Output Answer": [ + "$2^3\\cdot 13^1\\cdot 499^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(51896))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{767}{769}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2953733}-767}{1538}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(767/769)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{639,-797,-802\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 639, -797, -802\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{19}$\n$x \\equiv 7 \\pmod{20}$\n$x \\equiv 10 \\pmod{3}$", + "Output Answer": [ + "$1027$" + ], + "Output Program": [ + "constraints = (20, 19), (7, 20), (10, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 19), (7, 20), (10, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 19), (7, 20), (10, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n13915", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(13915))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22672 \\pmod{95}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(22672 % 95)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $334^m \\equiv 1 \\pmod{753}$.", + "Output Answer": [ + "$125$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(334, 753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26473 \\pmod{66}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(26473 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18221)$.", + "Output Answer": [ + "$14688$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $777^1580 \\pmod{858}$.", + "Output Answer": [ + "$243$" + ], + "Output Program": [ + "print(pow(777, 1580, 858))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n52973", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(52973))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $407^m \\equiv 1 \\pmod{420}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(407, 420))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $195^1951 \\pmod{1175}$.", + "Output Answer": [ + "$200$" + ], + "Output Program": [ + "print(pow(195, 1951, 1175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $202$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(202 % -38 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98128 \\pmod{13}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(98128 % 13)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n6011", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6011))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74636 \\pmod{87}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(74636 % 87)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $883x \\equiv 1 \\pmod{1200}$.", + "Output Answer": [ + "$1147$" + ], + "Output Program": [ + "print(pow(883, -1, 1200))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23581 \\pmod{43}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(23581 % 43)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{215,86\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 215, 86\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $137$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(137 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{842,-324\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 842, -324\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 13 \\pmod{8}$\n$x \\equiv 2 \\pmod{5}$", + "Output Answer": [ + "$117$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (13, 8), (2, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 11), (13, 8), (2, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 11), (13, 8), (2, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n7037", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7037))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-9145$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9145 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2941$ to base $4$.", + "Output Answer": [ + "$231331_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2941\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $189x \\equiv 1 \\pmod{752}$.", + "Output Answer": [ + "$565$" + ], + "Output Program": [ + "print(pow(189, -1, 752))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8016}{1753}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19137073}-4008}{1753}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8016/1753)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-978,928,91\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -978, 928, 91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{118,819,-335\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 118, 819, -335\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16603}{8701}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{578489213}-16603}{17402}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16603/8701)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25749)$.", + "Output Answer": [ + "$17160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25749))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1122^1810 \\pmod{2597}$.", + "Output Answer": [ + "$331$" + ], + "Output Program": [ + "print(pow(1122, 1810, 2597))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4496 \\pmod{98}$.", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "print(4496 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97813", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97813))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $47x \\equiv 1 \\pmod{99}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(pow(47, -1, 99))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $955x \\equiv 1 \\pmod{1874}$.", + "Output Answer": [ + "$885$" + ], + "Output Program": [ + "print(pow(955, -1, 1874))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43766)$.", + "Output Answer": [ + "$21528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43766))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{9}$\n$x \\equiv 20 \\pmod{10}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "constraints = (2, 9), (20, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 9), (20, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 9), (20, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n58243", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(58243))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23333)$.", + "Output Answer": [ + "$23332$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23333))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $730x \\equiv 1 \\pmod{1941}$.", + "Output Answer": [ + "$343$" + ], + "Output Program": [ + "print(pow(730, -1, 1941))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-803$ is divisible by $40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-803 % 40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{9}$\n$x \\equiv 10 \\pmod{16}$", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "constraints = (7, 9), (10, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 9), (10, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 9), (10, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $137^m \\equiv 1 \\pmod{610}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(137, 610))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $13^m \\equiv 1 \\pmod{387}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(13, 387))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61065 \\pmod{28}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(61065 % 28)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{198,-132\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 198, -132\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1452^2433 \\pmod{1765}$.", + "Output Answer": [ + "$1752$" + ], + "Output Program": [ + "print(pow(1452, 2433, 1765))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{5}$\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 16 \\pmod{13}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 5), (12, 7), (16, 13), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 5), (12, 7), (16, 13), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 5), (12, 7), (16, 13), (10, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2535$ to base $2$.", + "Output Answer": [ + "$100111100111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2535\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $21x \\equiv 1 \\pmod{499}$.", + "Output Answer": [ + "$404$" + ], + "Output Program": [ + "print(pow(21, -1, 499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 13), (11, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 13), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 13), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n5151", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5151))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19924)$.", + "Output Answer": [ + "$9344$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $172^m \\equiv 1 \\pmod{873}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(172, 873))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $64_7$ to base 10.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "n = '64'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1423x \\equiv 1 \\pmod{2175}$.", + "Output Answer": [ + "$1987$" + ], + "Output Program": [ + "print(pow(1423, -1, 2175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-301$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-301 % -14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1011$ to base $11$.", + "Output Answer": [ + "$\\text{83a}_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1011\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1807^1997 \\pmod{2780}$.", + "Output Answer": [ + "$1807$" + ], + "Output Program": [ + "print(pow(1807, 1997, 2780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $463x \\equiv 1 \\pmod{560}$.", + "Output Answer": [ + "$127$" + ], + "Output Program": [ + "print(pow(463, -1, 560))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $676^2403 \\pmod{2753}$.", + "Output Answer": [ + "$1178$" + ], + "Output Program": [ + "print(pow(676, 2403, 2753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18534}{13913}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{279448858}-9267}{13913}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18534/13913)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-303$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-303 % -3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79993 \\pmod{21}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(79993 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18911}{458}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{916} \\left(\\sqrt{358464977}-18911\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18911/458)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $673^1974 \\pmod{1449}$.", + "Output Answer": [ + "$1198$" + ], + "Output Program": [ + "print(pow(673, 1974, 1449))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-25,2,-810\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -25, 2, -810\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3353}{1389}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18959893}-3353}{2778}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3353/1389)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $793^m \\equiv 1 \\pmod{798}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(793, 798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 3 \\pmod{10}$", + "Output Answer": [ + "$1383$" + ], + "Output Program": [ + "constraints = (6, 17), (15, 9), (3, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (15, 9), (3, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 17), (15, 9), (3, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 11 \\pmod{17}$", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "constraints = (15, 10), (11, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 10), (11, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 10), (11, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{16}$\n$x \\equiv 20 \\pmod{5}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 16), (20, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 16), (20, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 16), (20, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{3}$\n$x \\equiv 20 \\pmod{17}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 3), (20, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 3), (20, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 3), (20, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{40,-97,-437\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 40, -97, -437\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-400,-123\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -400, -123\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68342 \\pmod{28}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(68342 % 28)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92984 \\pmod{81}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(92984 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $902^1754 \\pmod{2911}$.", + "Output Answer": [ + "$1148$" + ], + "Output Program": [ + "print(pow(902, 1754, 2911))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1248$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1248 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $591^2400 \\pmod{2445}$.", + "Output Answer": [ + "$1281$" + ], + "Output Program": [ + "print(pow(591, 2400, 2445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1117$ to base $34$.", + "Output Answer": [ + "$\\text{wt}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1117\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $101110100100_2$ to base 10.", + "Output Answer": [ + "$2980$" + ], + "Output Program": [ + "n = '101110100100'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $719^m \\equiv 1 \\pmod{754}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(719, 754))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $193x \\equiv 1 \\pmod{432}$.", + "Output Answer": [ + "$385$" + ], + "Output Program": [ + "print(pow(193, -1, 432))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $518x \\equiv 1 \\pmod{2391}$.", + "Output Answer": [ + "$1574$" + ], + "Output Program": [ + "print(pow(518, -1, 2391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{14}$\n$x \\equiv 11 \\pmod{12}$", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 14), (11, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 14), (11, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34100)$.", + "Output Answer": [ + "$12000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34100))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2243$ to base $2$.", + "Output Answer": [ + "$100011000011_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2243\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71675 \\pmod{73}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(71675 % 73)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $262x \\equiv 1 \\pmod{717}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(pow(262, -1, 717))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $598^2221 \\pmod{1852}$.", + "Output Answer": [ + "$312$" + ], + "Output Program": [ + "print(pow(598, 2221, 1852))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n89007", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89007))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $215^m \\equiv 1 \\pmod{814}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(215, 814))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-47421$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-47421 % 33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1495^196 \\pmod{2212}$.", + "Output Answer": [ + "$389$" + ], + "Output Program": [ + "print(pow(1495, 196, 2212))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9994}{2571}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1263202}-4997}{2571}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9994/2571)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2094^160 \\pmod{2820}$.", + "Output Answer": [ + "$996$" + ], + "Output Program": [ + "print(pow(2094, 160, 2820))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $109^m \\equiv 1 \\pmod{723}$.", + "Output Answer": [ + "$240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(109, 723))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.6050446_7$ to base 10.", + "Output Answer": [ + "$0.872$" + ], + "Output Program": [ + "n = '0.6050446'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63327 \\pmod{20}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(63327 % 20)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $87^m \\equiv 1 \\pmod{341}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(87, 341))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-299,-762\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -299, -762\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36345)$.", + "Output Answer": [ + "$19376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $61920$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(61920 % -43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8519}{6009}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{217005685}-8519}{12018}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8519/6009)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n74933", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(74933))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 8 \\pmod{19}$", + "Output Answer": [ + "$179$" + ], + "Output Program": [ + "constraints = (14, 15), (9, 5), (14, 15), (8, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 15), (9, 5), (14, 15), (8, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-757,610,748\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -757, 610, 748\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{273,-188\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 273, -188\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $407x \\equiv 1 \\pmod{1700}$.", + "Output Answer": [ + "$543$" + ], + "Output Program": [ + "print(pow(407, -1, 1700))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $319^m \\equiv 1 \\pmod{707}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(319, 707))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $98$.", + "Output Answer": [ + "$\\{3,5,17,33,45,47,59,61,73,75\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(98):\n if len(roots) == 10: break\n if gcd(a, 98) == 1 and is_primitive_root(a, 98):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $33120$.", + "Output Answer": [ + "$2^5\\cdot 3^2\\cdot 5^1\\cdot 23^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(33120))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1099^1472 \\pmod{1604}$.", + "Output Answer": [ + "$853$" + ], + "Output Program": [ + "print(pow(1099, 1472, 1604))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $29^2162 \\pmod{1911}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(pow(29, 2162, 1911))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51672 \\pmod{23}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(51672 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1651x \\equiv 1 \\pmod{1714}$.", + "Output Answer": [ + "$925$" + ], + "Output Program": [ + "print(pow(1651, -1, 1714))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41924)$.", + "Output Answer": [ + "$20424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $21630$ is divisible by $35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(21630 % 35 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $73^m \\equiv 1 \\pmod{96}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(73, 96))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{3}$\n$x \\equiv 17 \\pmod{20}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "import math\n\nconstraints = (11, 3), (17, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 3), (17, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 3), (17, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-40,-134,-318\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -40, -134, -318\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $117^493 \\pmod{665}$.", + "Output Answer": [ + "$572$" + ], + "Output Program": [ + "print(pow(117, 493, 665))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{8}$\n$x \\equiv 13 \\pmod{14}$\n$x \\equiv 11 \\pmod{20}$\n$x \\equiv 10 \\pmod{9}$", + "Output Answer": [ + "$811$" + ], + "Output Program": [ + "constraints = (19, 8), (13, 14), (11, 20), (10, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 8), (13, 14), (11, 20), (10, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41650 \\pmod{86}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(41650 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1576x \\equiv 1 \\pmod{1873}$.", + "Output Answer": [ + "$1482$" + ], + "Output Program": [ + "print(pow(1576, -1, 1873))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-562,-777,408\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -562, -777, 408\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-632,-761,496\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -632, -761, 496\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $10169$.", + "Output Answer": [ + "$\\{3,6,7,12,14,15,17,24,27,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(10169):\n if len(roots) == 10: break\n if gcd(a, 10169) == 1 and is_primitive_root(a, 10169):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $53x \\equiv 1 \\pmod{2140}$.", + "Output Answer": [ + "$1817$" + ], + "Output Program": [ + "print(pow(53, -1, 2140))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{398}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 398))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $46$ is divisible by $1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(46 % 1 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-848,346,681\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -848, 346, 681\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90145 \\pmod{36}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(90145 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n55667", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55667))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.712$ to base $32$.", + "Output Answer": [ + "$\\text{0.mp2q}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.712\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $327x \\equiv 1 \\pmod{2092}$.", + "Output Answer": [ + "$531$" + ], + "Output Program": [ + "print(pow(327, -1, 2092))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $42$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(42 % 8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1039x \\equiv 1 \\pmod{2146}$.", + "Output Answer": [ + "$1357$" + ], + "Output Program": [ + "print(pow(1039, -1, 2146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-986,-674,-331\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -986, -674, -331\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2939}{1798}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{74633}-2939}{3596}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2939/1798)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46473 \\pmod{34}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(46473 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 11 \\pmod{7}$", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 10), (11, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 10), (11, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 10), (11, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $230^245 \\pmod{1953}$.", + "Output Answer": [ + "$1091$" + ], + "Output Program": [ + "print(pow(230, 245, 1953))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $189^2407 \\pmod{2237}$.", + "Output Answer": [ + "$1098$" + ], + "Output Program": [ + "print(pow(189, 2407, 2237))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44737 \\pmod{36}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(44737 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1724^1578 \\pmod{2802}$.", + "Output Answer": [ + "$400$" + ], + "Output Program": [ + "print(pow(1724, 1578, 2802))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55719 \\pmod{67}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(55719 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-477$ is divisible by $23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-477 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{563}{80}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{160} \\left(\\sqrt{342569}-563\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(563/80)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $187x \\equiv 1 \\pmod{208}$.", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "print(pow(187, -1, 208))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84146 \\pmod{49}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(84146 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1665$ to base $18$.", + "Output Answer": [ + "$529_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1665\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 0 \\pmod{10}$\n$x \\equiv 7 \\pmod{17}$", + "Output Answer": [ + "$330$" + ], + "Output Program": [ + "constraints = (6, 6), (0, 10), (7, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (0, 10), (7, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58850 \\pmod{64}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(58850 % 64)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 5 \\pmod{14}$\n$x \\equiv 9 \\pmod{8}$", + "Output Answer": [ + "$481$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (5, 14), (9, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (5, 14), (9, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1659^50 \\pmod{2225}$.", + "Output Answer": [ + "$701$" + ], + "Output Program": [ + "print(pow(1659, 50, 2225))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-667$ is divisible by $-20$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-667 % -20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16973)$.", + "Output Answer": [ + "$15420$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16973))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1242^937 \\pmod{2514}$.", + "Output Answer": [ + "$2196$" + ], + "Output Program": [ + "print(pow(1242, 937, 2514))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $697x \\equiv 1 \\pmod{2012}$.", + "Output Answer": [ + "$433$" + ], + "Output Program": [ + "print(pow(697, -1, 2012))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $943x \\equiv 1 \\pmod{2223}$.", + "Output Answer": [ + "$1471$" + ], + "Output Program": [ + "print(pow(943, -1, 2223))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $918^2364 \\pmod{2956}$.", + "Output Answer": [ + "$1604$" + ], + "Output Program": [ + "print(pow(918, 2364, 2956))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5609}{11684}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{577524305}-5609}{23368}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5609/11684)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $737^2038 \\pmod{2530}$.", + "Output Answer": [ + "$1749$" + ], + "Output Program": [ + "print(pow(737, 2038, 2530))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 2 \\pmod{9}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 10), (3, 8), (2, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 10), (3, 8), (2, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10627)$.", + "Output Answer": [ + "$10626$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10627))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1406^1609 \\pmod{1619}$.", + "Output Answer": [ + "$202$" + ], + "Output Program": [ + "print(pow(1406, 1609, 1619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{31,681,-541\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 31, 681, -541\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $645^1549 \\pmod{736}$.", + "Output Answer": [ + "$277$" + ], + "Output Program": [ + "print(pow(645, 1549, 736))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55737 \\pmod{60}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(55737 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{148}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 148))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-378$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-378 % 14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $733x \\equiv 1 \\pmod{1427}$.", + "Output Answer": [ + "$183$" + ], + "Output Program": [ + "print(pow(733, -1, 1427))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $728$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(728 % 22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $349^474 \\pmod{1898}$.", + "Output Answer": [ + "$1013$" + ], + "Output Program": [ + "print(pow(349, 474, 1898))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{14}$\n$x \\equiv 1 \\pmod{8}$\n$x \\equiv 7 \\pmod{2}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "constraints = (7, 14), (1, 8), (7, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 14), (1, 8), (7, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{13}$\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 11 \\pmod{18}$\n$x \\equiv 14 \\pmod{19}$", + "Output Answer": [ + "$8165$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 13), (15, 10), (11, 18), (14, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 13), (15, 10), (11, 18), (14, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1635^1189 \\pmod{2909}$.", + "Output Answer": [ + "$2231$" + ], + "Output Program": [ + "print(pow(1635, 1189, 2909))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $383^m \\equiv 1 \\pmod{932}$.", + "Output Answer": [ + "$232$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(383, 932))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1108$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1108 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-276$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-276 % -8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $838^12 \\pmod{1768}$.", + "Output Answer": [ + "$1704$" + ], + "Output Program": [ + "print(pow(838, 12, 1768))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-962,-598\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -962, -598\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $539^m \\equiv 1 \\pmod{786}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(539, 786))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $38540$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(38540 % -41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $307x \\equiv 1 \\pmod{443}$.", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "print(pow(307, -1, 443))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{481}{4402}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{77741777}-481}{8804}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(481/4402)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1288$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1288 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{602}{2439}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6039322}-301}{2439}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(602/2439)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $193^m \\equiv 1 \\pmod{264}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(193, 264))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $72191$.", + "Output Answer": [ + "$7^1\\cdot 10313^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(72191))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $388x \\equiv 1 \\pmod{1439}$.", + "Output Answer": [ + "$1057$" + ], + "Output Program": [ + "print(pow(388, -1, 1439))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $78x \\equiv 1 \\pmod{155}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(pow(78, -1, 155))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1608^1427 \\pmod{2297}$.", + "Output Answer": [ + "$1097$" + ], + "Output Program": [ + "print(pow(1608, 1427, 2297))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n4993", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4993))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 4 \\pmod{11}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 5), (4, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 5), (4, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 5), (4, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1951x \\equiv 1 \\pmod{2430}$.", + "Output Answer": [ + "$1111$" + ], + "Output Program": [ + "print(pow(1951, -1, 2430))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{20}$\n$x \\equiv 0 \\pmod{13}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "constraints = (13, 20), (0, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 20), (0, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 20), (0, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $54721$.", + "Output Answer": [ + "$\\{11,22,29,31,41,44,47,55,73,79\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(54721):\n if len(roots) == 10: break\n if gcd(a, 54721) == 1 and is_primitive_root(a, 54721):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1687$ to base $22$.", + "Output Answer": [ + "$\\text{3af}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1687\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{838,697,-163\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 838, 697, -163\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79622 \\pmod{91}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "print(79622 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1141^2492 \\pmod{1403}$.", + "Output Answer": [ + "$164$" + ], + "Output Program": [ + "print(pow(1141, 2492, 1403))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67927 \\pmod{30}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(67927 % 30)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n89765", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89765))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{288,-827\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 288, -827\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $47^m \\equiv 1 \\pmod{575}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(47, 575))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2137^791 \\pmod{2895}$.", + "Output Answer": [ + "$973$" + ], + "Output Program": [ + "print(pow(2137, 791, 2895))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $5x \\equiv 1 \\pmod{774}$.", + "Output Answer": [ + "$155$" + ], + "Output Program": [ + "print(pow(5, -1, 774))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $704$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(704 % -11 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2_{28}$ to base 10.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "n = '2'.strip('.')\nbase = 28\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-984,-65,-455\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -984, -65, -455\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2403$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2403 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30061}{38426}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{272395745}-30061}{76852}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30061/38426)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10323}{15062}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1014019705}-10323}{30124}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10323/15062)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $246x \\equiv 1 \\pmod{1201}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "print(pow(246, -1, 1201))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50666 \\pmod{12}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(50666 % 12)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1244^1724 \\pmod{2798}$.", + "Output Answer": [ + "$1658$" + ], + "Output Program": [ + "print(pow(1244, 1724, 2798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3639}{5782}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{146968417}-3639}{11564}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3639/5782)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $247x \\equiv 1 \\pmod{2282}$.", + "Output Answer": [ + "$1663$" + ], + "Output Program": [ + "print(pow(247, -1, 2282))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $79934$.", + "Output Answer": [ + "$2^1\\cdot 17^1\\cdot 2351^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(79934))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $971x \\equiv 1 \\pmod{1502}$.", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "print(pow(971, -1, 1502))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18453}{11629}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{881447773}-18453}{23258}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18453/11629)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44640)$.", + "Output Answer": [ + "$11520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44640))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $423^366 \\pmod{2114}$.", + "Output Answer": [ + "$393$" + ], + "Output Program": [ + "print(pow(423, 366, 2114))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $39^m \\equiv 1 \\pmod{88}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(39, 88))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 6 \\pmod{11}$", + "Output Answer": [ + "$347$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 13), (14, 3), (6, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 13), (14, 3), (6, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (14, 3), (6, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2149^1858 \\pmod{2213}$.", + "Output Answer": [ + "$748$" + ], + "Output Program": [ + "print(pow(2149, 1858, 2213))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $681x \\equiv 1 \\pmod{1757}$.", + "Output Answer": [ + "$1628$" + ], + "Output Program": [ + "print(pow(681, -1, 1757))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $284x \\equiv 1 \\pmod{809}$.", + "Output Answer": [ + "$715$" + ], + "Output Program": [ + "print(pow(284, -1, 809))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2346^1112 \\pmod{2814}$.", + "Output Answer": [ + "$2346$" + ], + "Output Program": [ + "print(pow(2346, 1112, 2814))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{942}{769}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{769} \\left(\\sqrt{813202}-471\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(942/769)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{9}$\n$x \\equiv 10 \\pmod{13}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 9), (10, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 9), (10, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 9), (10, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $83^m \\equiv 1 \\pmod{566}$.", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(83, 566))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5624}{14527}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{218941073}-2812}{14527}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5624/14527)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33071)$.", + "Output Answer": [ + "$33070$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33071))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n25611", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(25611))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $127x \\equiv 1 \\pmod{380}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(pow(127, -1, 380))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-6279$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6279 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $639^1316 \\pmod{711}$.", + "Output Answer": [ + "$648$" + ], + "Output Program": [ + "print(pow(639, 1316, 711))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $741$ to base $24$.", + "Output Answer": [ + "$\\text{16l}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 741\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $109x \\equiv 1 \\pmod{1578}$.", + "Output Answer": [ + "$637$" + ], + "Output Program": [ + "print(pow(109, -1, 1578))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41539)$.", + "Output Answer": [ + "$41538$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41539))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46150)$.", + "Output Answer": [ + "$16800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46150))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12290)$.", + "Output Answer": [ + "$4912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12290))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4699}{2452}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46129817}-4699}{4904}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4699/2452)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $529^m \\equiv 1 \\pmod{643}$.", + "Output Answer": [ + "$321$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(529, 643))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{8}$\n$x \\equiv 13 \\pmod{2}$\n$x \\equiv 15 \\pmod{16}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 8), (13, 2), (15, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 8), (13, 2), (15, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4448}{26401}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{701958977}-2224}{26401}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4448/26401)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-126,-719\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -126, -719\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1421^652 \\pmod{1859}$.", + "Output Answer": [ + "$1192$" + ], + "Output Program": [ + "print(pow(1421, 652, 1859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n62499", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(62499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{161,-190,-941\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 161, -190, -941\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $813$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(813 % -31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9003}{3161}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{121021693}-9003}{6322}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9003/3161)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-238,312\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -238, 312\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $21053$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(21053 % 37 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{43365}{35869}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7026863869}-43365}{71738}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(43365/35869)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{816,708\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 816, 708\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3559}{2414}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{35976065}-3559}{4828}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3559/2414)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{907,763\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 907, 763\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-63,81\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -63, 81\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{24101}{27284}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{142340993}-24101}{54568}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24101/27284)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2405^1139 \\pmod{2458}$.", + "Output Answer": [ + "$1491$" + ], + "Output Program": [ + "print(pow(2405, 1139, 2458))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $9x \\equiv 1 \\pmod{1121}$.", + "Output Answer": [ + "$872$" + ], + "Output Program": [ + "print(pow(9, -1, 1121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7022)$.", + "Output Answer": [ + "$3510$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7022))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-217,612,330\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -217, 612, 330\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 14), (7, 17), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 14), (7, 17), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{332,577\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 332, 577\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $149^m \\equiv 1 \\pmod{228}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(149, 228))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39097)$.", + "Output Answer": [ + "$39096$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39097))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22513}{41392}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{294401033}-22513}{82784}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22513/41392)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $597^m \\equiv 1 \\pmod{724}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(597, 724))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{43,-971,-108\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 43, -971, -108\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{14}$\n$x \\equiv 18 \\pmod{19}$", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 14), (18, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 14), (18, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 14), (18, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-260$ is divisible by $-20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-260 % -20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2884 \\pmod{22}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(2884 % 22)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1740^1106 \\pmod{1741}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(1740, 1106, 1741))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $357^m \\equiv 1 \\pmod{592}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(357, 592))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n84313", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(84313))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $47x \\equiv 1 \\pmod{516}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(47, -1, 516))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $36497$.", + "Output Answer": [ + "$\\{3,5,6,7,10,11,12,13,14,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(36497):\n if len(roots) == 10: break\n if gcd(a, 36497) == 1 and is_primitive_root(a, 36497):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{9}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 11 \\pmod{3}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 9), (11, 11), (11, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 9), (11, 11), (11, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{825,412,-931\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 825, 412, -931\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1664^732 \\pmod{2753}$.", + "Output Answer": [ + "$2095$" + ], + "Output Program": [ + "print(pow(1664, 732, 2753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24258)$.", + "Output Answer": [ + "$7440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24258))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2263)$.", + "Output Answer": [ + "$2160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2263))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{21955}{10618}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{932989721}-21955}{21236}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21955/10618)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n102843", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102843))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 9 \\pmod{7}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 3), (6, 6), (9, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 3), (6, 6), (9, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-592,-956\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -592, -956\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17217)$.", + "Output Answer": [ + "$11472$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17217))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1724x \\equiv 1 \\pmod{1935}$.", + "Output Answer": [ + "$1559$" + ], + "Output Program": [ + "print(pow(1724, -1, 1935))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2232^2400 \\pmod{2364}$.", + "Output Answer": [ + "$888$" + ], + "Output Program": [ + "print(pow(2232, 2400, 2364))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37009)$.", + "Output Answer": [ + "$29760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37009))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-80$ is divisible by $4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-80 % 4 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $31_{24}$ to base 10.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "n = '31'.strip('.')\nbase = 24\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1529^821 \\pmod{2489}$.", + "Output Answer": [ + "$1563$" + ], + "Output Program": [ + "print(pow(1529, 821, 2489))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31816 \\pmod{34}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(31816 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{7}$\n$x \\equiv 20 \\pmod{4}$\n$x \\equiv 0 \\pmod{19}$\n$x \\equiv 10 \\pmod{14}$", + "Output Answer": [ + "$304$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 7), (20, 4), (0, 19), (10, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 7), (20, 4), (0, 19), (10, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16739}{38166}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6106768345}-16739}{76332}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16739/38166)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9437)$.", + "Output Answer": [ + "$9436$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9437))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 15 \\pmod{8}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "import math\n\nconstraints = (15, 19), (15, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 19), (15, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 19), (15, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1377x \\equiv 1 \\pmod{1744}$.", + "Output Answer": [ + "$1169$" + ], + "Output Program": [ + "print(pow(1377, -1, 1744))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2962$ to base $9$.", + "Output Answer": [ + "$4051_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2962\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44369", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $28347$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(28347 % -33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $14472$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(14472 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12804}{12115}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{187758829}-6402}{12115}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12804/12115)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{5}$\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 3 \\pmod{12}$", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "constraints = (12, 5), (20, 11), (3, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 5), (20, 11), (3, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 5), (20, 11), (3, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $367x \\equiv 1 \\pmod{2078}$.", + "Output Answer": [ + "$419$" + ], + "Output Program": [ + "print(pow(367, -1, 2078))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{628,-413\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 628, -413\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45924)$.", + "Output Answer": [ + "$14784$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1548^1036 \\pmod{1831}$.", + "Output Answer": [ + "$1406$" + ], + "Output Program": [ + "print(pow(1548, 1036, 1831))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $164x \\equiv 1 \\pmod{1995}$.", + "Output Answer": [ + "$1034$" + ], + "Output Program": [ + "print(pow(164, -1, 1995))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86505 \\pmod{25}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(86505 % 25)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34316 \\pmod{100}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(34316 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{25896}{2765}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{175295929}-12948}{2765}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25896/2765)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{97}{112}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{224} \\left(\\sqrt{59585}-97\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(97/112)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7566)$.", + "Output Answer": [ + "$2304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7566))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31363)$.", + "Output Answer": [ + "$30888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31363))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-390,78,-125\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -390, 78, -125\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $371x \\equiv 1 \\pmod{1766}$.", + "Output Answer": [ + "$1647$" + ], + "Output Program": [ + "print(pow(371, -1, 1766))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-860,-370\\}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "import math\n\nvalues = -860, -370\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{277}{294}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{588} \\left(\\sqrt{422473}-277\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(277/294)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $329^m \\equiv 1 \\pmod{780}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(329, 780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $315^m \\equiv 1 \\pmod{712}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(315, 712))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 2 \\pmod{10}$", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "constraints = (6, 6), (2, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (2, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $141^400 \\pmod{1015}$.", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "print(pow(141, 400, 1015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{697,775\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 697, 775\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $414x \\equiv 1 \\pmod{1015}$.", + "Output Answer": [ + "$939$" + ], + "Output Program": [ + "print(pow(414, -1, 1015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-505,-210\\}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nvalues = -505, -210\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14597)$.", + "Output Answer": [ + "$13260$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14597))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{91,-148,938\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 91, -148, 938\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{673,511\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 673, 511\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $20352$ is divisible by $48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(20352 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{378}$.", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "print(pow(37, -1, 378))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n55603", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55603))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39594 \\pmod{52}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(39594 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.431$ to base $17$.", + "Output Answer": [ + "$0.75989_{17}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 17\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.431\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-100,935,-106\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -100, 935, -106\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $461^883 \\pmod{1543}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(pow(461, 883, 1543))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44772 \\pmod{61}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(44772 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6334}{16533}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{283369978}-3167}{16533}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6334/16533)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1127}{4040}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{66556529}-1127}{8080}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1127/4040)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1373x \\equiv 1 \\pmod{2273}$.", + "Output Answer": [ + "$346$" + ], + "Output Program": [ + "print(pow(1373, -1, 2273))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11284}{5287}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{59784533}-5642}{5287}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11284/5287)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{790,428\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 790, 428\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17384}{4355}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{94516889}-8692}{4355}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17384/4355)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $449x \\equiv 1 \\pmod{1324}$.", + "Output Answer": [ + "$1209$" + ], + "Output Program": [ + "print(pow(449, -1, 1324))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{141}{3128}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{39157417}-141}{6256}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(141/3128)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83296 \\pmod{78}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "print(83296 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{686}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 686))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1700^1694 \\pmod{2128}$.", + "Output Answer": [ + "$176$" + ], + "Output Program": [ + "print(pow(1700, 1694, 2128))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2741}{9222}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{347694217}-2741}{18444}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2741/9222)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{283,-384\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 283, -384\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31642)$.", + "Output Answer": [ + "$14592$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{327,69\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = 327, 69\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $373x \\equiv 1 \\pmod{1712}$.", + "Output Answer": [ + "$1533$" + ], + "Output Program": [ + "print(pow(373, -1, 1712))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $42566$.", + "Output Answer": [ + "$\\{11,21,23,29,35,37,43,51,53,57\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(42566):\n if len(roots) == 10: break\n if gcd(a, 42566) == 1 and is_primitive_root(a, 42566):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7089 \\pmod{52}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(7089 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 14 \\pmod{3}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 17), (14, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 17), (14, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 17), (14, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.56$ to base $28$.", + "Output Answer": [ + "$\\text{0.fj13}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.56\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1977^301 \\pmod{2031}$.", + "Output Answer": [ + "$225$" + ], + "Output Program": [ + "print(pow(1977, 301, 2031))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n16185", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16185))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 12 \\pmod{14}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 5), (12, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 5), (12, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (12, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $107x \\equiv 1 \\pmod{624}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(pow(107, -1, 624))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $91126$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(91126 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-1,0,4\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -1, 0, 4\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27001)$.", + "Output Answer": [ + "$23760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27001))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{3}$\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 18 \\pmod{4}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$158$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 3), (17, 3), (18, 4), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 3), (17, 3), (18, 4), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.895$ to base $25$.", + "Output Answer": [ + "$\\text{0.m999}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.895\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $18922$.", + "Output Answer": [ + "$\\{3,15,21,27,31,53,61,69,73,75\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(18922):\n if len(roots) == 10: break\n if gcd(a, 18922) == 1 and is_primitive_root(a, 18922):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2332}{2065}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5623781}-1166}{2065}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2332/2065)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1010022_3$ to base 10.", + "Output Answer": [ + "$818$" + ], + "Output Program": [ + "n = '1010022'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24251$.", + "Output Answer": [ + "$\\{6,10,13,14,18,22,23,24,34,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24251):\n if len(roots) == 10: break\n if gcd(a, 24251) == 1 and is_primitive_root(a, 24251):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $53x \\equiv 1 \\pmod{960}$.", + "Output Answer": [ + "$797$" + ], + "Output Program": [ + "print(pow(53, -1, 960))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7791)$.", + "Output Answer": [ + "$4368$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7791))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $438^m \\equiv 1 \\pmod{617}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(438, 617))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-155,109,146\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -155, 109, 146\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61794 \\pmod{47}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(61794 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $33641$.", + "Output Answer": [ + "$\\{3,6,7,12,15,23,27,31,33,35\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(33641):\n if len(roots) == 10: break\n if gcd(a, 33641) == 1 and is_primitive_root(a, 33641):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n12301", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12301))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $16779$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(16779 % 47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{12}$\n$x \\equiv 5 \\pmod{11}$", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 12), (5, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 12), (5, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 12), (5, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $890x \\equiv 1 \\pmod{1923}$.", + "Output Answer": [ + "$1022$" + ], + "Output Program": [ + "print(pow(890, -1, 1923))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{13}$\n$x \\equiv 20 \\pmod{5}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "constraints = (5, 13), (20, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 13), (20, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 13), (20, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19814 \\pmod{19}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(19814 % 19)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $201^m \\equiv 1 \\pmod{956}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(201, 956))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{776,-380\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 776, -380\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n81815", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(81815))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n66357", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{12}$\n$x \\equiv 8 \\pmod{2}$\n$x \\equiv 1 \\pmod{13}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "constraints = (4, 12), (8, 2), (1, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 12), (8, 2), (1, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $1276$.", + "Output Answer": [ + "$2^2\\cdot 11^1\\cdot 29^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(1276))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{361,-465\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 361, -465\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35760)$.", + "Output Answer": [ + "$9472$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35760))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $736$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(736 % -16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5284 \\pmod{61}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(5284 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $390^1160 \\pmod{1354}$.", + "Output Answer": [ + "$954$" + ], + "Output Program": [ + "print(pow(390, 1160, 1354))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $16^m \\equiv 1 \\pmod{259}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(16, 259))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $184^m \\equiv 1 \\pmod{807}$.", + "Output Answer": [ + "$268$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(184, 807))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $879x \\equiv 1 \\pmod{1310}$.", + "Output Answer": [ + "$1079$" + ], + "Output Program": [ + "print(pow(879, -1, 1310))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n66601", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66601))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $327_{17}$ to base 10.", + "Output Answer": [ + "$908$" + ], + "Output Program": [ + "n = '327'.strip('.')\nbase = 17\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{18}$\n$x \\equiv 19 \\pmod{13}$", + "Output Answer": [ + "$201$" + ], + "Output Program": [ + "constraints = (3, 18), (19, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 18), (19, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 18), (19, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{34247}{7788}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1415468785}-34247}{15576}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34247/7788)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $707^1392 \\pmod{1246}$.", + "Output Answer": [ + "$217$" + ], + "Output Program": [ + "print(pow(707, 1392, 1246))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $10428$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(10428 % -44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.3$ to base $19$.", + "Output Answer": [ + "$\\text{0.5d5d6}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.3\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $688x \\equiv 1 \\pmod{1889}$.", + "Output Answer": [ + "$788$" + ], + "Output Program": [ + "print(pow(688, -1, 1889))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11467}{705}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{133480189}-11467}{1410}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11467/705)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $178^m \\equiv 1 \\pmod{643}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(178, 643))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n13679", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(13679))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2203_8$ to base 10.", + "Output Answer": [ + "$1155$" + ], + "Output Program": [ + "n = '2203'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $177^m \\equiv 1 \\pmod{704}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(177, 704))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{313}{747}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2330005}-313}{1494}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(313/747)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26036)$.", + "Output Answer": [ + "$12408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26036))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1107^367 \\pmod{1347}$.", + "Output Answer": [ + "$1053$" + ], + "Output Program": [ + "print(pow(1107, 367, 1347))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10127}{22219}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2077291973}-10127}{44438}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10127/22219)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12221}{1627}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{159941357}-12221}{3254}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12221/1627)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72165 \\pmod{93}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "print(72165 % 93)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5661}{5324}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{5817073}-5661}{10648}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5661/5324)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29725)$.", + "Output Answer": [ + "$22400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29725))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{435,71,238\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 435, 71, 238\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-185,301,759\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -185, 301, 759\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $809^1325 \\pmod{2309}$.", + "Output Answer": [ + "$142$" + ], + "Output Program": [ + "print(pow(809, 1325, 2309))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-332,-319,390\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -332, -319, 390\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{20635}{10531}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{869411069}-20635}{21062}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20635/10531)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7938$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7938 % -21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $41x \\equiv 1 \\pmod{266}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(41, -1, 266))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $695$ to base $8$.", + "Output Answer": [ + "$1267_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 695\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-898,-426\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -898, -426\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1422$ to base $5$.", + "Output Answer": [ + "$21142_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1422\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97478 \\pmod{44}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(97478 % 44)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $27^m \\equiv 1 \\pmod{281}$.", + "Output Answer": [ + "$280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(27, 281))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43141)$.", + "Output Answer": [ + "$36972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43141))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41361 \\pmod{2}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(41361 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $151x \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$177$" + ], + "Output Program": [ + "print(pow(151, -1, 322))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22231)$.", + "Output Answer": [ + "$19320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22231))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-10728$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10728 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 3 \\pmod{18}$\n$x \\equiv 15 \\pmod{4}$", + "Output Answer": [ + "$255$" + ], + "Output Program": [ + "constraints = (2, 11), (3, 18), (15, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 11), (3, 18), (15, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5529}{12592}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{664803697}-5529}{25184}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5529/12592)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-361,-6\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -361, -6\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{10}$\n$x \\equiv 13 \\pmod{16}$", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 10), (13, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 10), (13, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89910 \\pmod{16}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(89910 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $90^m \\equiv 1 \\pmod{179}$.", + "Output Answer": [ + "$178$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(90, 179))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{237,817\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 237, 817\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25669)$.", + "Output Answer": [ + "$20736$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25669))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $161^m \\equiv 1 \\pmod{949}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(161, 949))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $80174$.", + "Output Answer": [ + "$2^1\\cdot 40087^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(80174))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1292^1254 \\pmod{2276}$.", + "Output Answer": [ + "$2164$" + ], + "Output Program": [ + "print(pow(1292, 1254, 2276))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{24755}{2463}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{637075501}-24755}{4926}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24755/2463)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $968^382 \\pmod{2633}$.", + "Output Answer": [ + "$1673$" + ], + "Output Program": [ + "print(pow(968, 382, 2633))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{69}{1369}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7501405}-69}{2738}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(69/1369)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-865,-503,786\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -865, -503, 786\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39397)$.", + "Output Answer": [ + "$39396$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39397))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.896$ to base $36$.", + "Output Answer": [ + "$\\text{0.w97s}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.896\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 7 \\pmod{14}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 17), (7, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 17), (7, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 17), (7, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{752,-644,461\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 752, -644, 461\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10987 \\pmod{89}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(10987 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5621}{6238}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{187246217}-5621}{12476}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5621/6238)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1581^2047 \\pmod{1714}$.", + "Output Answer": [ + "$1659$" + ], + "Output Program": [ + "print(pow(1581, 2047, 1714))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-122,-439\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -122, -439\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $507x \\equiv 1 \\pmod{1414}$.", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "print(pow(507, -1, 1414))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46968 \\pmod{63}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(46968 % 63)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $265x \\equiv 1 \\pmod{2026}$.", + "Output Answer": [ + "$1789$" + ], + "Output Program": [ + "print(pow(265, -1, 2026))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2071^1794 \\pmod{2186}$.", + "Output Answer": [ + "$1457$" + ], + "Output Program": [ + "print(pow(2071, 1794, 2186))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{734,546\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 734, 546\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8494}{14467}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{227331098}-4247}{14467}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8494/14467)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{929,-517,803\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 929, -517, 803\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35931 \\pmod{16}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(35931 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n18721", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18721))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34227)$.", + "Output Answer": [ + "$22812$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87371 \\pmod{78}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(87371 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $503^m \\equiv 1 \\pmod{814}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(503, 814))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2021^770 \\pmod{2107}$.", + "Output Answer": [ + "$1978$" + ], + "Output Program": [ + "print(pow(2021, 770, 2107))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28727)$.", + "Output Answer": [ + "$27456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28727))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1299}{3295}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{156109}-1299}{6590}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1299/3295)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-586,514\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -586, 514\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34776)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34776))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1267x \\equiv 1 \\pmod{1280}$.", + "Output Answer": [ + "$1083$" + ], + "Output Program": [ + "print(pow(1267, -1, 1280))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17198)$.", + "Output Answer": [ + "$8598$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17198))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78778 \\pmod{53}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(78778 % 53)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $156^m \\equiv 1 \\pmod{647}$.", + "Output Answer": [ + "$323$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(156, 647))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88079 \\pmod{15}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(88079 % 15)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96180 \\pmod{71}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(96180 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.91$ to base $11$.", + "Output Answer": [ + "$\\text{0.a01234}_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.91\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-379,146,-255\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -379, 146, -255\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{421,531\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 421, 531\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1449^317 \\pmod{2556}$.", + "Output Answer": [ + "$1125$" + ], + "Output Program": [ + "print(pow(1449, 317, 2556))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 18029 \\pmod{37}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(18029 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94720 \\pmod{31}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(94720 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.00111111111_5$ to base 10.", + "Output Answer": [ + "$0.01$" + ], + "Output Program": [ + "n = '0.00111111111'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $909$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(909 % -9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7$ is divisible by $1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7 % 1 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $789$ to base $35$.", + "Output Answer": [ + "$\\text{mj}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 789\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n70997", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70997))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1646$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1646 % -49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{12}$\n$x \\equiv 9 \\pmod{20}$\n$x \\equiv 0 \\pmod{7}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 12), (9, 20), (0, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 12), (9, 20), (0, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 20 \\pmod{18}$", + "Output Answer": [ + "$2882$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 13), (13, 19), (20, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 13), (13, 19), (20, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (13, 19), (20, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-162,812,251\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -162, 812, 251\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $49x \\equiv 1 \\pmod{558}$.", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "print(pow(49, -1, 558))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $11^m \\equiv 1 \\pmod{25}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(11, 25))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $35^1199 \\pmod{770}$.", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "print(pow(35, 1199, 770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2363}{46311}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8584418653}-2363}{92622}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2363/46311)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $49$ to base $6$.", + "Output Answer": [ + "$121_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 49\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $76^450 \\pmod{1187}$.", + "Output Answer": [ + "$333$" + ], + "Output Program": [ + "print(pow(76, 450, 1187))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44659)$.", + "Output Answer": [ + "$40320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44659))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13486}{4789}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{68402570}-6743}{4789}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13486/4789)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $132^1510 \\pmod{1650}$.", + "Output Answer": [ + "$924$" + ], + "Output Program": [ + "print(pow(132, 1510, 1650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47709)$.", + "Output Answer": [ + "$29160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47709))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{62,-876\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 62, -876\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{8}$\n$x \\equiv 10 \\pmod{3}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 8), (10, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 8), (10, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 8), (10, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $49897$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(49897 % -41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $265x \\equiv 1 \\pmod{988}$.", + "Output Answer": [ + "$645$" + ], + "Output Program": [ + "print(pow(265, -1, 988))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $387x \\equiv 1 \\pmod{2093}$.", + "Output Answer": [ + "$914$" + ], + "Output Program": [ + "print(pow(387, -1, 2093))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33468)$.", + "Output Answer": [ + "$11152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33468))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $151x \\equiv 1 \\pmod{342}$.", + "Output Answer": [ + "$265$" + ], + "Output Program": [ + "print(pow(151, -1, 342))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41939 \\pmod{62}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(41939 % 62)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9869}{8647}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{396479597}-9869}{17294}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9869/8647)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6455}{32471}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4259130389}-6455}{64942}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6455/32471)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2$ to base $15$.", + "Output Answer": [ + "$2_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $22822$.", + "Output Answer": [ + "$\\{7,11,19,21,23,29,33,35,41,57\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(22822):\n if len(roots) == 10: break\n if gcd(a, 22822) == 1 and is_primitive_root(a, 22822):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(242)$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(242))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $591x \\equiv 1 \\pmod{1436}$.", + "Output Answer": [ + "$571$" + ], + "Output Program": [ + "print(pow(591, -1, 1436))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 14 \\pmod{4}$\n$x \\equiv 3 \\pmod{5}$", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 3), (14, 4), (3, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 3), (14, 4), (3, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (14, 4), (3, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1092^622 \\pmod{1714}$.", + "Output Answer": [ + "$678$" + ], + "Output Program": [ + "print(pow(1092, 622, 1714))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-162,162,143\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -162, 162, 143\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-4,-3,2\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = -4, -3, 2\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{12}$\n$x \\equiv 1 \\pmod{2}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 12), (1, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 12), (1, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n69265", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(69265))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{358}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 358))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $201$ to base $3$.", + "Output Answer": [ + "$21110_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 201\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7247$.", + "Output Answer": [ + "$\\{5,7,10,11,13,14,15,17,20,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7247):\n if len(roots) == 10: break\n if gcd(a, 7247) == 1 and is_primitive_root(a, 7247):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $857$ to base $18$.", + "Output Answer": [ + "$\\text{2bb}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 857\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26539)$.", + "Output Answer": [ + "$26538$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26539))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1225x \\equiv 1 \\pmod{1446}$.", + "Output Answer": [ + "$229$" + ], + "Output Program": [ + "print(pow(1225, -1, 1446))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-392,17,-606\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -392, 17, -606\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1598^2017 \\pmod{1964}$.", + "Output Answer": [ + "$1300$" + ], + "Output Program": [ + "print(pow(1598, 2017, 1964))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-894,-234,25\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -894, -234, 25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $53^m \\equiv 1 \\pmod{368}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(53, 368))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2253^1447 \\pmod{2724}$.", + "Output Answer": [ + "$957$" + ], + "Output Program": [ + "print(pow(2253, 1447, 2724))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2256^345 \\pmod{2571}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(pow(2256, 345, 2571))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{855,-336\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 855, -336\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38684 \\pmod{24}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(38684 % 24)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1835^2183 \\pmod{2815}$.", + "Output Answer": [ + "$2265$" + ], + "Output Program": [ + "print(pow(1835, 2183, 2815))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $296^m \\equiv 1 \\pmod{939}$.", + "Output Answer": [ + "$312$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(296, 939))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11363)$.", + "Output Answer": [ + "$10320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11363))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1624^923 \\pmod{2419}$.", + "Output Answer": [ + "$1193$" + ], + "Output Program": [ + "print(pow(1624, 923, 2419))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 12 \\pmod{16}$", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 14), (12, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 14), (12, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{987}{862}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3946345}-987}{1724}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(987/862)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{6}$\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 2 \\pmod{11}$", + "Output Answer": [ + "$420$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 6), (0, 7), (6, 6), (2, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 6), (0, 7), (6, 6), (2, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $309^1350 \\pmod{2503}$.", + "Output Answer": [ + "$1063$" + ], + "Output Program": [ + "print(pow(309, 1350, 2503))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{292}{6813}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46438285}-146}{6813}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(292/6813)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $281$.", + "Output Answer": [ + "$\\{3,11,12,13,15,19,21,22,23,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(281):\n if len(roots) == 10: break\n if gcd(a, 281) == 1 and is_primitive_root(a, 281):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{3,-3,-3,-1\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = 3, -3, -3, -1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1811x \\equiv 1 \\pmod{2136}$.", + "Output Answer": [ + "$1091$" + ], + "Output Program": [ + "print(pow(1811, -1, 2136))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $170^1011 \\pmod{2761}$.", + "Output Answer": [ + "$2425$" + ], + "Output Program": [ + "print(pow(170, 1011, 2761))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $491^m \\equiv 1 \\pmod{754}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(491, 754))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38893 \\pmod{66}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(38893 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72830 \\pmod{99}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(72830 % 99)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{252}$.", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "print(pow(79, -1, 252))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1450)$.", + "Output Answer": [ + "$560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1450))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21462)$.", + "Output Answer": [ + "$6048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97299", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97299))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $95^m \\equiv 1 \\pmod{216}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(95, 216))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1463$ is divisible by $19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1463 % 19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $4123_6$ to base 10.", + "Output Answer": [ + "$915$" + ], + "Output Program": [ + "n = '4123'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $804^313 \\pmod{2359}$.", + "Output Answer": [ + "$405$" + ], + "Output Program": [ + "print(pow(804, 313, 2359))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $46034$.", + "Output Answer": [ + "$2^1\\cdot 23017^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(46034))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1425}{1048}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6423841}-1425}{2096}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1425/1048)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $96x \\equiv 1 \\pmod{2371}$.", + "Output Answer": [ + "$1309$" + ], + "Output Program": [ + "print(pow(96, -1, 2371))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.824$ to base $8$.", + "Output Answer": [ + "$0.6457065_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.824\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41238 \\pmod{57}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(41238 % 57)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1274x \\equiv 1 \\pmod{2391}$.", + "Output Answer": [ + "$929$" + ], + "Output Program": [ + "print(pow(1274, -1, 2391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{6}$\n$x \\equiv 4 \\pmod{11}$", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 6), (4, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 6), (4, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 6), (4, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3944}{34803}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1215137593}-1972}{34803}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3944/34803)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 0 \\pmod{6}$\n$x \\equiv 8 \\pmod{14}$", + "Output Answer": [ + "$708$" + ], + "Output Program": [ + "constraints = (4, 11), (13, 5), (0, 6), (8, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 11), (13, 5), (0, 6), (8, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-920,59,-848\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -920, 59, -848\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1316)$.", + "Output Answer": [ + "$552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1316))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2409^609 \\pmod{2699}$.", + "Output Answer": [ + "$1661$" + ], + "Output Program": [ + "print(pow(2409, 609, 2699))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $879^1889 \\pmod{1121}$.", + "Output Answer": [ + "$175$" + ], + "Output Program": [ + "print(pow(879, 1889, 1121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{15}$\n$x \\equiv 8 \\pmod{6}$\n$x \\equiv 17 \\pmod{9}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 15), (8, 6), (17, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 15), (8, 6), (17, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{712}{6261}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{39326857}-356}{6261}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(712/6261)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $521x \\equiv 1 \\pmod{670}$.", + "Output Answer": [ + "$661$" + ], + "Output Program": [ + "print(pow(521, -1, 670))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $153^m \\equiv 1 \\pmod{869}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(153, 869))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-827,641\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -827, 641\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-596,-83,917\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -596, -83, 917\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n94777", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(94777))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n5013", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5013))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $125^m \\equiv 1 \\pmod{356}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(125, 356))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $648$ is divisible by $4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(648 % 4 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21273)$.", + "Output Answer": [ + "$12144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21273))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26184 \\pmod{61}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(26184 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1473$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1473 % -32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10588)$.", + "Output Answer": [ + "$5292$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10588))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $452^1317 \\pmod{1496}$.", + "Output Answer": [ + "$584$" + ], + "Output Program": [ + "print(pow(452, 1317, 1496))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $378^m \\equiv 1 \\pmod{409}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(378, 409))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{51,-310,74\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 51, -310, 74\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97173", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97173))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $93501$.", + "Output Answer": [ + "$3^3\\cdot 3463^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(93501))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-146,-418\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -146, -418\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{560,110\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 560, 110\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{737,288,434\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 737, 288, 434\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74138 \\pmod{36}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(74138 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $973x \\equiv 1 \\pmod{1437}$.", + "Output Answer": [ + "$511$" + ], + "Output Program": [ + "print(pow(973, -1, 1437))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4571)$.", + "Output Answer": [ + "$3912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4571))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n39507", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(39507))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-85828$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-85828 % -43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-700,322\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -700, 322\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 8 \\pmod{2}$\n$x \\equiv 1 \\pmod{9}$", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "constraints = (8, 19), (8, 2), (1, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (8, 2), (1, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 19), (8, 2), (1, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $147x \\equiv 1 \\pmod{932}$.", + "Output Answer": [ + "$615$" + ], + "Output Program": [ + "print(pow(147, -1, 932))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{15}$\n$x \\equiv 11 \\pmod{14}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 15 \\pmod{11}$", + "Output Answer": [ + "$4547$" + ], + "Output Program": [ + "constraints = (17, 15), (11, 14), (3, 4), (15, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 15), (11, 14), (3, 4), (15, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29077$.", + "Output Answer": [ + "$\\{2,5,6,7,15,17,22,23,24,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29077):\n if len(roots) == 10: break\n if gcd(a, 29077) == 1 and is_primitive_root(a, 29077):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{6}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 11 \\pmod{6}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "constraints = (11, 6), (7, 7), (11, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 6), (7, 7), (11, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $56160$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(56160 % 40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n7541", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7541))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-625,-885\\}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nvalues = -625, -885\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-37968$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-37968 % -42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $601^m \\equiv 1 \\pmod{630}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(601, 630))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $167^m \\equiv 1 \\pmod{234}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(167, 234))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $643x \\equiv 1 \\pmod{2317}$.", + "Output Answer": [ + "$209$" + ], + "Output Program": [ + "print(pow(643, -1, 2317))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $426x \\equiv 1 \\pmod{2051}$.", + "Output Answer": [ + "$727$" + ], + "Output Program": [ + "print(pow(426, -1, 2051))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $251_9$ to base 10.", + "Output Answer": [ + "$208$" + ], + "Output Program": [ + "n = '251'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22339}{23062}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2626454297}-22339}{46124}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22339/23062)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $13^703 \\pmod{2971}$.", + "Output Answer": [ + "$1891$" + ], + "Output Program": [ + "print(pow(13, 703, 2971))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n10323", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10323))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $187^860 \\pmod{1254}$.", + "Output Answer": [ + "$517$" + ], + "Output Program": [ + "print(pow(187, 860, 1254))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{46}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 46))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n50501", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50501))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n70575", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70575))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60891 \\pmod{96}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(60891 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n76541", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76541))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1434^1266 \\pmod{1949}$.", + "Output Answer": [ + "$876$" + ], + "Output Program": [ + "print(pow(1434, 1266, 1949))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2359^106 \\pmod{2923}$.", + "Output Answer": [ + "$2310$" + ], + "Output Program": [ + "print(pow(2359, 106, 2923))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $176^m \\equiv 1 \\pmod{909}$.", + "Output Answer": [ + "$300$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(176, 909))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $33660$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(33660 % -30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1507^1954 \\pmod{2710}$.", + "Output Answer": [ + "$789$" + ], + "Output Program": [ + "print(pow(1507, 1954, 2710))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11179}{18822}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1542040777}-11179}{37644}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11179/18822)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-762,71,-202\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -762, 71, -202\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24865)$.", + "Output Answer": [ + "$19888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24865))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2422$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2422 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{12}$\n$x \\equiv 10 \\pmod{5}$", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 12), (10, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 12), (10, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 12), (10, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-872,-97,679\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -872, -97, 679\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1253^1298 \\pmod{2966}$.", + "Output Answer": [ + "$2753$" + ], + "Output Program": [ + "print(pow(1253, 1298, 2966))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12528)$.", + "Output Answer": [ + "$4032$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12528))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38659)$.", + "Output Answer": [ + "$38016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38659))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33780 \\pmod{94}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(33780 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{16}$\n$x \\equiv 17 \\pmod{16}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "constraints = (17, 16), (17, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 16), (17, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{983,-661\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 983, -661\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $98353$.", + "Output Answer": [ + "$59^1\\cdot 1667^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(98353))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $163^m \\equiv 1 \\pmod{334}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(163, 334))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $589^m \\equiv 1 \\pmod{616}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(589, 616))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-588$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-588 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22610)$.", + "Output Answer": [ + "$6912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22610))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41665 \\pmod{94}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(41665 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $103^m \\equiv 1 \\pmod{498}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(103, 498))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3872 \\pmod{49}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(3872 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-789,196\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -789, 196\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $56^874 \\pmod{497}$.", + "Output Answer": [ + "$161$" + ], + "Output Program": [ + "print(pow(56, 874, 497))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1792$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1792 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $493^m \\equiv 1 \\pmod{692}$.", + "Output Answer": [ + "$172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(493, 692))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12829}{17020}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1323304841}-12829}{34040}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12829/17020)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{833}{2082}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18032785}-833}{4164}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(833/2082)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1656}{5647}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{32574193}-828}{5647}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1656/5647)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $63828$ is divisible by $36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(63828 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{785}{5626}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{127223729}-785}{11252}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(785/5626)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49715 \\pmod{46}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(49715 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n50119", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50119))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-985,-229\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -985, -229\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $827x \\equiv 1 \\pmod{2075}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "print(pow(827, -1, 2075))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1638$ to base $25$.", + "Output Answer": [ + "$\\text{2fd}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1638\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.932$ to base $34$.", + "Output Answer": [ + "$\\text{0.vndb}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.932\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{64,-958,247\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 64, -958, 247\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $614_{15}$ to base 10.", + "Output Answer": [ + "$1369$" + ], + "Output Program": [ + "n = '614'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-60900$ is divisible by $35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-60900 % 35 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1395$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1395 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1592^433 \\pmod{2793}$.", + "Output Answer": [ + "$2390$" + ], + "Output Program": [ + "print(pow(1592, 433, 2793))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $24194$.", + "Output Answer": [ + "$\\{5,13,15,17,35,37,39,51,59,73\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(24194):\n if len(roots) == 10: break\n if gcd(a, 24194) == 1 and is_primitive_root(a, 24194):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $835x \\equiv 1 \\pmod{2216}$.", + "Output Answer": [ + "$2147$" + ], + "Output Program": [ + "print(pow(835, -1, 2216))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-804,-182\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -804, -182\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9615)$.", + "Output Answer": [ + "$5120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9615))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90217 \\pmod{90}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(90217 % 90)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $322$ to base $21$.", + "Output Answer": [ + "$\\text{f7}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 322\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $201$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(201 % -3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{338}{81}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{81} \\left(\\sqrt{35122}-169\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(338/81)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $9^2169 \\pmod{1240}$.", + "Output Answer": [ + "$1089$" + ], + "Output Program": [ + "print(pow(9, 2169, 1240))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $422$ to base $24$.", + "Output Answer": [ + "$\\text{he}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 422\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.67$ to base $32$.", + "Output Answer": [ + "$\\text{0.le2i}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.67\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $635^m \\equiv 1 \\pmod{666}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(635, 666))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n43323", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43323))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16384)$.", + "Output Answer": [ + "$8192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16384))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-69264$ is divisible by $48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-69264 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $685^1986 \\pmod{803}$.", + "Output Answer": [ + "$289$" + ], + "Output Program": [ + "print(pow(685, 1986, 803))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $698$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(698 % 8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $212^2284 \\pmod{1385}$.", + "Output Answer": [ + "$1351$" + ], + "Output Program": [ + "print(pow(212, 2284, 1385))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{15}$\n$x \\equiv 11 \\pmod{4}$", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 15), (11, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 15), (11, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 15), (11, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2569)$.", + "Output Answer": [ + "$2196$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2569))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $102^m \\equiv 1 \\pmod{485}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(102, 485))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n59369", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n33223", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33223))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $751x \\equiv 1 \\pmod{2029}$.", + "Output Answer": [ + "$154$" + ], + "Output Program": [ + "print(pow(751, -1, 2029))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $650$ to base $2$.", + "Output Answer": [ + "$1010001010_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 650\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{311}{5016}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{100737745}-311}{10032}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(311/5016)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n100551", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(100551))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $627x \\equiv 1 \\pmod{1130}$.", + "Output Answer": [ + "$483$" + ], + "Output Program": [ + "print(pow(627, -1, 1130))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1140^1591 \\pmod{2035}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(pow(1140, 1591, 2035))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $39779$.", + "Output Answer": [ + "$\\{2,6,8,10,11,14,18,23,24,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(39779):\n if len(roots) == 10: break\n if gcd(a, 39779) == 1 and is_primitive_root(a, 39779):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{7}$\n$x \\equiv 15 \\pmod{20}$", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 7), (15, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 7), (15, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 7), (15, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $191x \\equiv 1 \\pmod{2037}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(pow(191, -1, 2037))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-76440$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-76440 % -49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32396)$.", + "Output Answer": [ + "$12672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32396))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $47x \\equiv 1 \\pmod{1240}$.", + "Output Answer": [ + "$343$" + ], + "Output Program": [ + "print(pow(47, -1, 1240))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32140)$.", + "Output Answer": [ + "$12848$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32140))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{467}{2094}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{17757433}-467}{4188}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(467/2094)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-94$ is divisible by $-13$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-94 % -13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=4$ $34$-gonal number.\n", + "Output Answer": [ + "$1156$" + ], + "Output Program": [ + "n = 4\nk = 34\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $491^m \\equiv 1 \\pmod{936}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(491, 936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1064^21 \\pmod{2699}$.", + "Output Answer": [ + "$2287$" + ], + "Output Program": [ + "print(pow(1064, 21, 2699))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60514 \\pmod{75}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(60514 % 75)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99882 \\pmod{27}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(99882 % 27)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n43209", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43209))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{589,588\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 589, 588\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84675 \\pmod{8}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(84675 % 8)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72133 \\pmod{43}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(72133 % 43)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $219^m \\equiv 1 \\pmod{722}$.", + "Output Answer": [ + "$342$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(219, 722))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{203,-350\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 203, -350\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{269}$.", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 269))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $13^m \\equiv 1 \\pmod{213}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(13, 213))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1952x \\equiv 1 \\pmod{2049}$.", + "Output Answer": [ + "$1880$" + ], + "Output Program": [ + "print(pow(1952, -1, 2049))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27261)$.", + "Output Answer": [ + "$16704$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{640,787,-255\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 640, 787, -255\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96395 \\pmod{59}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(96395 % 59)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $803^2032 \\pmod{1860}$.", + "Output Answer": [ + "$541$" + ], + "Output Program": [ + "print(pow(803, 2032, 1860))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 7 \\pmod{14}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 3), (7, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 3), (7, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (7, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 19 \\pmod{17}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 13), (19, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 13), (19, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 13), (19, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63760 \\pmod{34}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(63760 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1758}{847}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{847} \\left(5 \\sqrt{59602}-879\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1758/847)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $3192$ is divisible by $8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3192 % 8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{413,500,837\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 413, 500, 837\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2346$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2346 % -49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $833x \\equiv 1 \\pmod{2314}$.", + "Output Answer": [ + "$2289$" + ], + "Output Program": [ + "print(pow(833, -1, 2314))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{89}{3902}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{60910337}-89}{7804}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(89/3902)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-9400$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9400 % 40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $238x \\equiv 1 \\pmod{1585}$.", + "Output Answer": [ + "$1272$" + ], + "Output Program": [ + "print(pow(238, -1, 1585))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1144x \\equiv 1 \\pmod{1363}$.", + "Output Answer": [ + "$473$" + ], + "Output Program": [ + "print(pow(1144, -1, 1363))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $185^m \\equiv 1 \\pmod{856}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(185, 856))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $459x \\equiv 1 \\pmod{1328}$.", + "Output Answer": [ + "$515$" + ], + "Output Program": [ + "print(pow(459, -1, 1328))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $9^m \\equiv 1 \\pmod{14}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(9, 14))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43250)$.", + "Output Answer": [ + "$17200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43250))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23427)$.", + "Output Answer": [ + "$14688$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23427))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n15617", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(15617))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5090}{6307}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46255274}-2545}{6307}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5090/6307)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $525^m \\equiv 1 \\pmod{746}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(525, 746))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38160)$.", + "Output Answer": [ + "$9984$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38160))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $337^m \\equiv 1 \\pmod{378}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(337, 378))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{85,-546,474\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 85, -546, 474\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 17 \\pmod{6}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 17), (17, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 17), (17, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 17), (17, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{4}$\n$x \\equiv 2 \\pmod{19}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 4), (2, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 4), (2, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 4), (2, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-765$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-765 % 5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3175)$.", + "Output Answer": [ + "$2520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6465)$.", + "Output Answer": [ + "$3440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6465))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38994)$.", + "Output Answer": [ + "$12672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38994))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $12792$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(12792 % -41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14536)$.", + "Output Answer": [ + "$6864$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14536))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $21821$.", + "Output Answer": [ + "$\\{2,8,10,11,12,13,14,15,18,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(21821):\n if len(roots) == 10: break\n if gcd(a, 21821) == 1 and is_primitive_root(a, 21821):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1900$ to base $12$.", + "Output Answer": [ + "$1124_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1900\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87171 \\pmod{47}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(87171 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{208,-987,239\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 208, -987, 239\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{16}$\n$x \\equiv 0 \\pmod{18}$", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 16), (0, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 16), (0, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{8}$\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 20 \\pmod{19}$", + "Output Answer": [ + "$1084$" + ], + "Output Program": [ + "constraints = (12, 8), (6, 11), (20, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 8), (6, 11), (20, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 8), (6, 11), (20, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{26877}{14888}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1608983305}-26877}{29776}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26877/14888)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 8 \\pmod{7}$\n$x \\equiv 3 \\pmod{12}$\n$x \\equiv 15 \\pmod{10}$", + "Output Answer": [ + "$2955$" + ], + "Output Program": [ + "constraints = (4, 13), (8, 7), (3, 12), (15, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 13), (8, 7), (3, 12), (15, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2312$ to base $18$.", + "Output Answer": [ + "$728_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2312\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1531^1005 \\pmod{2499}$.", + "Output Answer": [ + "$2092$" + ], + "Output Program": [ + "print(pow(1531, 1005, 2499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 5 \\pmod{6}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "import math\n\nconstraints = (11, 17), (5, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 17), (5, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 17), (5, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $84970$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 29^1\\cdot 293^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(84970))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{10}$\n$x \\equiv 4 \\pmod{18}$\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 20 \\pmod{11}$", + "Output Answer": [ + "$4288$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 10), (4, 18), (4, 17), (20, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 10), (4, 18), (4, 17), (20, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $64097$.", + "Output Answer": [ + "$11^1\\cdot 5827^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(64097))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $299^m \\equiv 1 \\pmod{635}$.", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(299, 635))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2071^1614 \\pmod{2088}$.", + "Output Answer": [ + "$289$" + ], + "Output Program": [ + "print(pow(2071, 1614, 2088))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9267}{43336}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7597912873}-9267}{86672}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9267/43336)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16617 \\pmod{100}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(16617 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10903}{11356}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{634710353}-10903}{22712}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10903/11356)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27645)$.", + "Output Answer": [ + "$13824$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27645))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(619)$.", + "Output Answer": [ + "$618$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $607x \\equiv 1 \\pmod{2221}$.", + "Output Answer": [ + "$794$" + ], + "Output Program": [ + "print(pow(607, -1, 2221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $29930$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 41^1\\cdot 73^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(29930))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11421}{3884}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{190781065}-11421}{7768}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11421/3884)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n99677", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(99677))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-806,205,517\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -806, 205, 517\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 18 \\pmod{5}$", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 9), (18, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 9), (18, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 9), (18, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24496 \\pmod{55}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(24496 % 55)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{340,33,-40\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 340, 33, -40\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{26,716,365\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 26, 716, 365\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37207)$.", + "Output Answer": [ + "$35896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37207))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14303}{42390}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7392224209}-14303}{84780}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14303/42390)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{183,28,921\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 183, 28, 921\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{47,602,119\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 47, 602, 119\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31821)$.", + "Output Answer": [ + "$21212$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31821))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13410)$.", + "Output Answer": [ + "$3552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13410))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-197,-176\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -197, -176\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-688$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-688 % 16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{805}$.", + "Output Answer": [ + "$718$" + ], + "Output Program": [ + "print(pow(37, -1, 805))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{8}$\n$x \\equiv 17 \\pmod{12}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 8), (17, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 8), (17, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{758,521,682\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 758, 521, 682\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2296^1542 \\pmod{2959}$.", + "Output Answer": [ + "$394$" + ], + "Output Program": [ + "print(pow(2296, 1542, 2959))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $212^m \\equiv 1 \\pmod{943}$.", + "Output Answer": [ + "$440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(212, 943))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53453$.", + "Output Answer": [ + "$\\{2,3,5,8,12,14,17,20,21,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53453):\n if len(roots) == 10: break\n if gcd(a, 53453) == 1 and is_primitive_root(a, 53453):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5337)$.", + "Output Answer": [ + "$3552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5337))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $843$ to base $9$.", + "Output Answer": [ + "$1136_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 843\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76529 \\pmod{44}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(76529 % 44)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91735 \\pmod{24}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(91735 % 24)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5202$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5202 % 18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2992$ to base $33$.", + "Output Answer": [ + "$\\text{2om}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2992\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $144^m \\equiv 1 \\pmod{293}$.", + "Output Answer": [ + "$146$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(144, 293))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $893^m \\equiv 1 \\pmod{910}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(893, 910))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $379^m \\equiv 1 \\pmod{770}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(379, 770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1065$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1065 % -9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1149^106 \\pmod{1404}$.", + "Output Answer": [ + "$1377$" + ], + "Output Program": [ + "print(pow(1149, 106, 1404))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $168$ is divisible by $41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(168 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1180^115 \\pmod{1211}$.", + "Output Answer": [ + "$1173$" + ], + "Output Program": [ + "print(pow(1180, 115, 1211))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $244^m \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(244, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-520,424\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -520, 424\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-707,312\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -707, 312\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2238^20 \\pmod{2464}$.", + "Output Answer": [ + "$1376$" + ], + "Output Program": [ + "print(pow(2238, 20, 2464))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 15 \\pmod{9}$", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (15, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 7), (15, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 7), (15, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53115", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53115))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{171,139\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 171, 139\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-361,675\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -361, 675\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10035)$.", + "Output Answer": [ + "$5328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10035))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{19}$\n$x \\equiv 0 \\pmod{6}$\n$x \\equiv 0 \\pmod{11}$", + "Output Answer": [ + "$330$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 19), (0, 6), (0, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 19), (0, 6), (0, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 19), (0, 6), (0, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $314^m \\equiv 1 \\pmod{945}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(314, 945))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $303x \\equiv 1 \\pmod{1697}$.", + "Output Answer": [ + "$1669$" + ], + "Output Program": [ + "print(pow(303, -1, 1697))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $802x \\equiv 1 \\pmod{2059}$.", + "Output Answer": [ + "$896$" + ], + "Output Program": [ + "print(pow(802, -1, 2059))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{101,576,432\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 101, 576, 432\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $789^m \\equiv 1 \\pmod{904}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(789, 904))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76183 \\pmod{74}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(76183 % 74)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28642)$.", + "Output Answer": [ + "$14320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-127$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-127 % 19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $767x \\equiv 1 \\pmod{1289}$.", + "Output Answer": [ + "$1168$" + ], + "Output Program": [ + "print(pow(767, -1, 1289))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-933,-567\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -933, -567\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1195^2086 \\pmod{1910}$.", + "Output Answer": [ + "$1195$" + ], + "Output Program": [ + "print(pow(1195, 2086, 1910))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-28014$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-28014 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-417,-823\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -417, -823\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n80689", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(80689))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 19 \\pmod{13}$", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "constraints = (4, 16), (19, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 16), (19, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 16), (19, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58290 \\pmod{39}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(58290 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2653)$.", + "Output Answer": [ + "$2268$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2653))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{6}$\n$x \\equiv 5 \\pmod{3}$\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 18 \\pmod{2}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 6), (5, 3), (0, 20), (18, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 6), (5, 3), (0, 20), (18, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1643x \\equiv 1 \\pmod{2185}$.", + "Output Answer": [ + "$1157$" + ], + "Output Program": [ + "print(pow(1643, -1, 2185))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $719x \\equiv 1 \\pmod{773}$.", + "Output Answer": [ + "$501$" + ], + "Output Program": [ + "print(pow(719, -1, 773))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{95}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 95))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n9533", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $385$ is divisible by $26$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(385 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42444)$.", + "Output Answer": [ + "$14040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42444))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-42763$ is divisible by $41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-42763 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1123^2379 \\pmod{1605}$.", + "Output Answer": [ + "$1027$" + ], + "Output Program": [ + "print(pow(1123, 2379, 1605))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17099}{34323}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5004649117}-17099}{68646}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17099/34323)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-204,38,87\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -204, 38, 87\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $83^m \\equiv 1 \\pmod{130}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(83, 130))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1983$ to base $11$.", + "Output Answer": [ + "$1543_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1983\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-452,693,964\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -452, 693, 964\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 9 \\pmod{15}$", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "constraints = (4, 16), (9, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 16), (9, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 16), (9, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2186$ to base $28$.", + "Output Answer": [ + "$\\text{2m2}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2186\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3980}{2689}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{11190821}-1990}{2689}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3980/2689)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $970^1149 \\pmod{2424}$.", + "Output Answer": [ + "$856$" + ], + "Output Program": [ + "print(pow(970, 1149, 2424))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $175^1177 \\pmod{1610}$.", + "Output Answer": [ + "$735$" + ], + "Output Program": [ + "print(pow(175, 1177, 1610))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $457^m \\equiv 1 \\pmod{764}$.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(457, 764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70823 \\pmod{18}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(70823 % 18)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $21x \\equiv 1 \\pmod{62}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(pow(21, -1, 62))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $456$ to base $32$.", + "Output Answer": [ + "$\\text{e8}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 456\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $129^m \\equiv 1 \\pmod{266}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(129, 266))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-12936$ is divisible by $28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-12936 % 28 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-689$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-689 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1767^1519 \\pmod{1798}$.", + "Output Answer": [ + "$713$" + ], + "Output Program": [ + "print(pow(1767, 1519, 1798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{19}$\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 0 \\pmod{18}$", + "Output Answer": [ + "$2322$" + ], + "Output Program": [ + "constraints = (4, 19), (1, 11), (0, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 19), (1, 11), (0, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 19), (1, 11), (0, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1185}{1033}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5672581}-1185}{2066}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1185/1033)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $862$.", + "Output Answer": [ + "$\\{7,13,17,21,31,35,37,39,43,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(862):\n if len(roots) == 10: break\n if gcd(a, 862) == 1 and is_primitive_root(a, 862):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1134x \\equiv 1 \\pmod{2453}$.", + "Output Answer": [ + "$716$" + ], + "Output Program": [ + "print(pow(1134, -1, 2453))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{706,-524,243\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 706, -524, 243\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91136 \\pmod{40}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(91136 % 40)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1616^1677 \\pmod{2660}$.", + "Output Answer": [ + "$1616$" + ], + "Output Program": [ + "print(pow(1616, 1677, 2660))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $997^1857 \\pmod{2688}$.", + "Output Answer": [ + "$2533$" + ], + "Output Program": [ + "print(pow(997, 1857, 2688))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $355^m \\equiv 1 \\pmod{738}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(355, 738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52324 \\pmod{91}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "print(52324 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{737}{1296}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7261633}-737}{2592}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(737/1296)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-730,153\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -730, 153\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-101,-765\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -101, -765\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-775,693\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -775, 693\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1098$ to base $14$.", + "Output Answer": [ + "$586_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1098\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $625x \\equiv 1 \\pmod{2464}$.", + "Output Answer": [ + "$753$" + ], + "Output Program": [ + "print(pow(625, -1, 2464))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 81502 \\pmod{50}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(81502 % 50)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1536^2070 \\pmod{2834}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(pow(1536, 2070, 2834))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34913)$.", + "Output Answer": [ + "$34912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34913))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1715}{2641}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{30840749}-1715}{5282}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1715/2641)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.76$ to base $8$.", + "Output Answer": [ + "$0.6050754_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.76\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $200^690 \\pmod{1569}$.", + "Output Answer": [ + "$1561$" + ], + "Output Program": [ + "print(pow(200, 690, 1569))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87583 \\pmod{10}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(87583 % 10)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{919,535\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 919, 535\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{396,63,236\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 396, 63, 236\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{19}$\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 20 \\pmod{13}$\n$x \\equiv 7 \\pmod{16}$", + "Output Answer": [ + "$28295$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 19), (14, 11), (20, 13), (7, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 19), (14, 11), (20, 13), (7, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 19), (14, 11), (20, 13), (7, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $18821$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18821 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{14}$\n$x \\equiv 3 \\pmod{6}$\n$x \\equiv 9 \\pmod{16}$", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 14), (3, 6), (9, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 14), (3, 6), (9, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65709 \\pmod{67}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(65709 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1248$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1248 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $185^m \\equiv 1 \\pmod{844}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(185, 844))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3718}{4715}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{25687106}-1859}{4715}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3718/4715)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n31975", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31975))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24127)$.", + "Output Answer": [ + "$23056$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24127))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $184x \\equiv 1 \\pmod{1341}$.", + "Output Answer": [ + "$430$" + ], + "Output Program": [ + "print(pow(184, -1, 1341))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58958 \\pmod{98}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(58958 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9361}{15150}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1005718321}-9361}{30300}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9361/15150)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49585 \\pmod{68}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(49585 % 68)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1605^473 \\pmod{1738}$.", + "Output Answer": [ + "$593$" + ], + "Output Program": [ + "print(pow(1605, 473, 1738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $491^m \\equiv 1 \\pmod{803}$.", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(491, 803))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $687x \\equiv 1 \\pmod{952}$.", + "Output Answer": [ + "$855$" + ], + "Output Program": [ + "print(pow(687, -1, 952))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{6}$\n$x \\equiv 1 \\pmod{5}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 6), (1, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (20, 6), (1, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 6), (1, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{10,-20,11\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 10, -20, 11\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $130^1226 \\pmod{595}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "print(pow(130, 1226, 595))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{325}{3079}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{38026589}-325}{6158}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(325/3079)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.69359_{15}$ to base 10.", + "Output Answer": [ + "$0.441$" + ], + "Output Program": [ + "n = '0.69359'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.597$ to base $28$.", + "Output Answer": [ + "$\\text{0.gk1a}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.597\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1248x \\equiv 1 \\pmod{2155}$.", + "Output Answer": [ + "$1542$" + ], + "Output Program": [ + "print(pow(1248, -1, 2155))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1434^1128 \\pmod{1888}$.", + "Output Answer": [ + "$1344$" + ], + "Output Program": [ + "print(pow(1434, 1128, 1888))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43184)$.", + "Output Answer": [ + "$21584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43184))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1213x \\equiv 1 \\pmod{2497}$.", + "Output Answer": [ + "$422$" + ], + "Output Program": [ + "print(pow(1213, -1, 2497))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83502 \\pmod{94}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(83502 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1697^1054 \\pmod{2755}$.", + "Output Answer": [ + "$2039$" + ], + "Output Program": [ + "print(pow(1697, 1054, 2755))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16757 \\pmod{74}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(16757 % 74)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $61008$ is divisible by $41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(61008 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $330x \\equiv 1 \\pmod{721}$.", + "Output Answer": [ + "$260$" + ], + "Output Program": [ + "print(pow(330, -1, 721))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{349,323,-456\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 349, 323, -456\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $6106$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6106 % -43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23893 \\pmod{9}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(23893 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $171^m \\equiv 1 \\pmod{356}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(171, 356))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $75^m \\equiv 1 \\pmod{98}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(75, 98))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1512^195 \\pmod{1852}$.", + "Output Answer": [ + "$560$" + ], + "Output Program": [ + "print(pow(1512, 195, 1852))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $337x \\equiv 1 \\pmod{1008}$.", + "Output Answer": [ + "$673$" + ], + "Output Program": [ + "print(pow(337, -1, 1008))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 5 \\pmod{2}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "constraints = (11, 10), (5, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 10), (5, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{609,-901\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 609, -901\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-2,3\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -2, 3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $836^2216 \\pmod{1916}$.", + "Output Answer": [ + "$528$" + ], + "Output Program": [ + "print(pow(836, 2216, 1916))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $831^2456 \\pmod{1711}$.", + "Output Answer": [ + "$1196$" + ], + "Output Program": [ + "print(pow(831, 2456, 1711))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $463^m \\equiv 1 \\pmod{516}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(463, 516))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19845)$.", + "Output Answer": [ + "$9072$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19845))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $33479$.", + "Output Answer": [ + "$\\{17,19,34,37,38,51,57,59,61,68\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(33479):\n if len(roots) == 10: break\n if gcd(a, 33479) == 1 and is_primitive_root(a, 33479):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5528}{3731}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{21560057}-2764}{3731}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5528/3731)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $33x \\equiv 1 \\pmod{1964}$.", + "Output Answer": [ + "$1845$" + ], + "Output Program": [ + "print(pow(33, -1, 1964))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 2 \\pmod{8}$", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 7), (2, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 7), (2, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 7), (2, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27222}{1085}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{186436546}-13611}{1085}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27222/1085)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $370^m \\equiv 1 \\pmod{513}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(370, 513))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{814,975,801\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 814, 975, 801\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $221^m \\equiv 1 \\pmod{784}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(221, 784))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $94x \\equiv 1 \\pmod{793}$.", + "Output Answer": [ + "$464$" + ], + "Output Program": [ + "print(pow(94, -1, 793))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8333}{24486}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2467695673}-8333}{48972}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8333/24486)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n29031", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(29031))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.2332232011_4$ to base 10.", + "Output Answer": [ + "$0.745$" + ], + "Output Program": [ + "n = '0.2332232011'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-427,-245,38\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -427, -245, 38\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-916,-667\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -916, -667\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n51191", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51191))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 10 \\pmod{7}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 5), (10, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 5), (10, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 5), (10, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $21x \\equiv 1 \\pmod{2315}$.", + "Output Answer": [ + "$441$" + ], + "Output Program": [ + "print(pow(21, -1, 2315))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9243}{7510}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{311033449}-9243}{15020}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9243/7510)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{411,-742,152\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 411, -742, 152\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $991x \\equiv 1 \\pmod{1156}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(991, -1, 1156))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $837^m \\equiv 1 \\pmod{962}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(837, 962))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3000}{2633}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9182689}-1500}{2633}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3000/2633)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $544^2499 \\pmod{2591}$.", + "Output Answer": [ + "$1074$" + ], + "Output Program": [ + "print(pow(544, 2499, 2591))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $61x \\equiv 1 \\pmod{264}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(61, -1, 264))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $87x \\equiv 1 \\pmod{179}$.", + "Output Answer": [ + "$107$" + ], + "Output Program": [ + "print(pow(87, -1, 179))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{329,-514,432\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 329, -514, 432\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1619^1197 \\pmod{2946}$.", + "Output Answer": [ + "$1205$" + ], + "Output Program": [ + "print(pow(1619, 1197, 2946))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48335)$.", + "Output Answer": [ + "$33120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48335))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{3}$\n$x \\equiv 18 \\pmod{14}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 3), (18, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 3), (18, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 3), (18, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $505^m \\equiv 1 \\pmod{713}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(505, 713))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38645)$.", + "Output Answer": [ + "$30160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38645))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $123^m \\equiv 1 \\pmod{227}$.", + "Output Answer": [ + "$226$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(123, 227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{2}$\n$x \\equiv 3 \\pmod{13}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "constraints = (17, 2), (3, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 2), (3, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 2), (3, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{43736}{39999}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{83125177}-21868}{39999}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(43736/39999)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n82915", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82915))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{6}$\n$x \\equiv 16 \\pmod{17}$", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 6), (16, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 6), (16, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 6), (16, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1011x \\equiv 1 \\pmod{1366}$.", + "Output Answer": [ + "$177$" + ], + "Output Program": [ + "print(pow(1011, -1, 1366))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1386^866 \\pmod{1577}$.", + "Output Answer": [ + "$343$" + ], + "Output Program": [ + "print(pow(1386, 866, 1577))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1323^1650 \\pmod{1740}$.", + "Output Answer": [ + "$789$" + ], + "Output Program": [ + "print(pow(1323, 1650, 1740))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $112$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(112 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33797 \\pmod{82}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(33797 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2500^817 \\pmod{2677}$.", + "Output Answer": [ + "$547$" + ], + "Output Program": [ + "print(pow(2500, 817, 2677))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{13}$\n$x \\equiv 18 \\pmod{16}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 13), (18, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 13), (18, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 13), (18, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $203x \\equiv 1 \\pmod{286}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(pow(203, -1, 286))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{19}$\n$x \\equiv 17 \\pmod{17}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 19), (17, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 19), (17, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 19), (17, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37688 \\pmod{6}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(37688 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40077 \\pmod{69}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(40077 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4757}{13095}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{708545149}-4757}{26190}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4757/13095)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{865,194\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 865, 194\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{383}{87}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{174} \\left(\\sqrt{176965}-383\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(383/87)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1756^1275 \\pmod{2498}$.", + "Output Answer": [ + "$764$" + ], + "Output Program": [ + "print(pow(1756, 1275, 2498))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3281}{2457}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{34912357}-3281}{4914}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3281/2457)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5921)$.", + "Output Answer": [ + "$5700$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n5435", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5435))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $449x \\equiv 1 \\pmod{2292}$.", + "Output Answer": [ + "$1853$" + ], + "Output Program": [ + "print(pow(449, -1, 2292))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39961)$.", + "Output Answer": [ + "$39424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39961))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{321,-980,68\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 321, -980, 68\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{3}$\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 3 \\pmod{6}$\n$x \\equiv 0 \\pmod{3}$", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 3), (12, 13), (3, 6), (0, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 3), (12, 13), (3, 6), (0, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $368^1361 \\pmod{1582}$.", + "Output Answer": [ + "$562$" + ], + "Output Program": [ + "print(pow(368, 1361, 1582))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1753^159 \\pmod{2378}$.", + "Output Answer": [ + "$209$" + ], + "Output Program": [ + "print(pow(1753, 159, 2378))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $85698$.", + "Output Answer": [ + "$2^1\\cdot 3^4\\cdot 23^2$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(85698))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{231,-470,-585\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 231, -470, -585\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38700)$.", + "Output Answer": [ + "$10080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38700))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.539$ to base $23$.", + "Output Answer": [ + "$\\text{0.c93}_{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.539\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{12}$\n$x \\equiv 5 \\pmod{5}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 12), (5, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 12), (5, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 12), (5, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3349}{787}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{13693277}-3349}{1574}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3349/787)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $508_{15}$ to base 10.", + "Output Answer": [ + "$1133$" + ], + "Output Program": [ + "n = '508'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-3771$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3771 % 27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1884$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1884 % -18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 11 \\pmod{20}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (11, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 17), (11, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 17), (11, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-5138$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-5138 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42218)$.", + "Output Answer": [ + "$18000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42218))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $539^m \\equiv 1 \\pmod{871}$.", + "Output Answer": [ + "$132$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(539, 871))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39261)$.", + "Output Answer": [ + "$24992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-666$ is divisible by $29$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-666 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $537x \\equiv 1 \\pmod{766}$.", + "Output Answer": [ + "$97$" + ], + "Output Program": [ + "print(pow(537, -1, 766))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $2861$.", + "Output Answer": [ + "$\\{2,3,8,10,12,15,18,26,27,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(2861):\n if len(roots) == 10: break\n if gcd(a, 2861) == 1 and is_primitive_root(a, 2861):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $13127$.", + "Output Answer": [ + "$\\{5,7,10,11,14,15,17,19,20,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(13127):\n if len(roots) == 10: break\n if gcd(a, 13127) == 1 and is_primitive_root(a, 13127):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.615$ to base $8$.", + "Output Answer": [ + "$0.4727024_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.615\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38484)$.", + "Output Answer": [ + "$12816$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38484))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $81^m \\equiv 1 \\pmod{316}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(81, 316))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37198 \\pmod{21}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(37198 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1249x \\equiv 1 \\pmod{2121}$.", + "Output Answer": [ + "$1384$" + ], + "Output Program": [ + "print(pow(1249, -1, 2121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13126}{6401}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{84045770}-6563}{6401}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13126/6401)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1479$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1479 % -42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14626}{6269}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{92780330}-7313}{6269}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14626/6269)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45115)$.", + "Output Answer": [ + "$30912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45115))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{29,11,-480\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 29, 11, -480\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $851x \\equiv 1 \\pmod{1163}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "print(pow(851, -1, 1163))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15713 \\pmod{80}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(15713 % 80)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{20}$\n$x \\equiv 7 \\pmod{18}$", + "Output Answer": [ + "$97$" + ], + "Output Program": [ + "constraints = (17, 20), (7, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 20), (7, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{702}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 702))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n69859", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(69859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{438,-286\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 438, -286\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13897}{10428}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{628099345}-13897}{20856}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13897/10428)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8254$.", + "Output Answer": [ + "$\\{5,7,13,15,19,21,31,37,39,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8254):\n if len(roots) == 10: break\n if gcd(a, 8254) == 1 and is_primitive_root(a, 8254):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $863^694 \\pmod{1057}$.", + "Output Answer": [ + "$338$" + ], + "Output Program": [ + "print(pow(863, 694, 1057))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2047^1244 \\pmod{2565}$.", + "Output Answer": [ + "$1051$" + ], + "Output Program": [ + "print(pow(2047, 1244, 2565))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{130,-590\\}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "import math\n\nvalues = 130, -590\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $885^1335 \\pmod{2462}$.", + "Output Answer": [ + "$1789$" + ], + "Output Program": [ + "print(pow(885, 1335, 2462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $469^m \\equiv 1 \\pmod{498}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(469, 498))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48302)$.", + "Output Answer": [ + "$24150$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48302))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43948)$.", + "Output Answer": [ + "$21972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43948))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1447$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1447 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $799x \\equiv 1 \\pmod{1016}$.", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "print(pow(799, -1, 1016))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $45538$.", + "Output Answer": [ + "$\\{3,7,11,13,15,17,23,27,31,35\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(45538):\n if len(roots) == 10: break\n if gcd(a, 45538) == 1 and is_primitive_root(a, 45538):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{13}$\n$x \\equiv 11 \\pmod{6}$\n$x \\equiv 16 \\pmod{5}$", + "Output Answer": [ + "$161$" + ], + "Output Program": [ + "constraints = (18, 13), (11, 6), (16, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 13), (11, 6), (16, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 13), (11, 6), (16, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-682$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-682 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{7}$\n$x \\equiv 8 \\pmod{16}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "constraints = (17, 7), (8, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 7), (8, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 7), (8, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $8^m \\equiv 1 \\pmod{393}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(8, 393))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4843}{14872}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{908160185}-4843}{29744}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4843/14872)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53889", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53889))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4802}{2309}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{11096282}-2401}{2309}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4802/2309)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $738^2025 \\pmod{2887}$.", + "Output Answer": [ + "$1542$" + ], + "Output Program": [ + "print(pow(738, 2025, 2887))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 42084 \\pmod{51}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(42084 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $233_{13}$ to base 10.", + "Output Answer": [ + "$380$" + ], + "Output Program": [ + "n = '233'.strip('.')\nbase = 13\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $79$ is divisible by $10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(79 % 10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5723}{7154}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{237471593}-5723}{14308}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5723/7154)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 1 \\pmod{16}$\n$x \\equiv 14 \\pmod{19}$", + "Output Answer": [ + "$2161$" + ], + "Output Program": [ + "import math\n\nconstraints = (16, 11), (1, 16), (14, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 11), (1, 16), (14, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 11), (1, 16), (14, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n9929", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9929))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1268}{1593}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2939605}-634}{1593}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1268/1593)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5629)$.", + "Output Answer": [ + "$5184$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5629))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $493x \\equiv 1 \\pmod{1534}$.", + "Output Answer": [ + "$753$" + ], + "Output Program": [ + "print(pow(493, -1, 1534))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{323,-310,132\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 323, -310, 132\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $189x \\equiv 1 \\pmod{410}$.", + "Output Answer": [ + "$269$" + ], + "Output Program": [ + "print(pow(189, -1, 410))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $127^m \\equiv 1 \\pmod{175}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(127, 175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{924,101,-7\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 924, 101, -7\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{319}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 319))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{20423}{36250}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5673348929}-20423}{72500}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20423/36250)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44355", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44355))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{1,5,3,1\\}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "import math\n\nvalues = 1, 5, 3, 1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8342}{35529}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1279707082}-4171}{35529}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8342/35529)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30678)$.", + "Output Answer": [ + "$10224$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30678))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 15 \\pmod{3}$", + "Output Answer": [ + "$690$" + ], + "Output Program": [ + "constraints = (11, 7), (10, 5), (6, 19), (15, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (10, 5), (6, 19), (15, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 7), (10, 5), (6, 19), (15, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $787$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(787 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n92311", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(92311))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1554^1306 \\pmod{2796}$.", + "Output Answer": [ + "$1644$" + ], + "Output Program": [ + "print(pow(1554, 1306, 2796))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $233^m \\equiv 1 \\pmod{416}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(233, 416))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30637}{3232}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{980409065}-30637}{6464}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30637/3232)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 17 \\pmod{13}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 19), (17, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (17, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 19), (17, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9041}{26}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{52} \\left(\\sqrt{81742385}-9041\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9041/26)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-939,-452\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -939, -452\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{29747}{17038}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2046057785}-29747}{34076}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29747/17038)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5953}{27574}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3076740113}-5953}{55148}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5953/27574)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n86981", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(86981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $64^m \\equiv 1 \\pmod{205}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(64, 205))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8673 \\pmod{21}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(8673 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-634,951,375\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -634, 951, 375\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1403x \\equiv 1 \\pmod{1408}$.", + "Output Answer": [ + "$563$" + ], + "Output Program": [ + "print(pow(1403, -1, 1408))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1977$ to base $30$.", + "Output Answer": [ + "$\\text{25r}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1977\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46734)$.", + "Output Answer": [ + "$15576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46734))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1979x \\equiv 1 \\pmod{2108}$.", + "Output Answer": [ + "$719$" + ], + "Output Program": [ + "print(pow(1979, -1, 2108))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30894)$.", + "Output Answer": [ + "$9720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30894))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80208 \\pmod{46}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(80208 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8504}{2613}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{24907273}-4252}{2613}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8504/2613)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43651)$.", + "Output Answer": [ + "$43650$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43651))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 20 \\pmod{3}$\n$x \\equiv 8 \\pmod{20}$\n$x \\equiv 8 \\pmod{5}$", + "Output Answer": [ + "$248$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 13), (20, 3), (8, 20), (8, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 13), (20, 3), (8, 20), (8, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1612x \\equiv 1 \\pmod{2459}$.", + "Output Answer": [ + "$2369$" + ], + "Output Program": [ + "print(pow(1612, -1, 2459))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $19015$.", + "Output Answer": [ + "$5^1\\cdot 3803^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(19015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $29^m \\equiv 1 \\pmod{31}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(29, 31))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{374}{19803}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{392193778}-187}{19803}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(374/19803)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $7364$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7364 % -14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22928 \\pmod{82}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(22928 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 7 \\pmod{5}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 8), (7, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 8), (7, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 8), (7, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{199}{354}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{708} \\left(\\sqrt{540865}-199\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(199/354)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-31904$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-31904 % -32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $462$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(462 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $69452$.", + "Output Answer": [ + "$2^2\\cdot 97^1\\cdot 179^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(69452))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53946 \\pmod{98}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(53946 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{80,-111,-542\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 80, -111, -542\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $719^m \\equiv 1 \\pmod{750}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(719, 750))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89810 \\pmod{15}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(89810 % 15)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{930,-35\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 930, -35\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{116}{107}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{107} \\left(\\sqrt{14813}-58\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(116/107)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $667x \\equiv 1 \\pmod{1360}$.", + "Output Answer": [ + "$1203$" + ], + "Output Program": [ + "print(pow(667, -1, 1360))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n21105", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21105))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $298^m \\equiv 1 \\pmod{737}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(298, 737))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-3420$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3420 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $439x \\equiv 1 \\pmod{786}$.", + "Output Answer": [ + "$487$" + ], + "Output Program": [ + "print(pow(439, -1, 786))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $520^m \\equiv 1 \\pmod{933}$.", + "Output Answer": [ + "$155$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(520, 933))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5839 \\pmod{47}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(5839 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 5 \\pmod{3}$", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "constraints = (4, 5), (5, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 5), (5, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 5), (5, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34507 \\pmod{55}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(34507 % 55)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{17}$\n$x \\equiv 20 \\pmod{7}$\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 17 \\pmod{10}$", + "Output Answer": [ + "$3527$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 17), (20, 7), (7, 8), (17, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 17), (20, 7), (7, 8), (17, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{37289}{41317}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8218847477}-37289}{82634}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37289/41317)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56857 \\pmod{51}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(56857 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23619)$.", + "Output Answer": [ + "$15744$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1139)$.", + "Output Answer": [ + "$1056$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1139))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1462$ is divisible by $17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1462 % 17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $695$ to base $35$.", + "Output Answer": [ + "$\\text{ju}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 695\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $12650$.", + "Output Answer": [ + "$2^1\\cdot 5^2\\cdot 11^1\\cdot 23^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(12650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{31622}{18961}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{61 \\sqrt{163802}-15811}{18961}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31622/18961)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 6 \\pmod{3}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "constraints = (15, 10), (6, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 10), (6, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 10), (6, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3381}{2285}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{32316061}-3381}{4570}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3381/2285)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $269^m \\equiv 1 \\pmod{620}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(269, 620))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{20879}{35971}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5611584005}-20879}{71942}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20879/35971)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33828)$.", + "Output Answer": [ + "$11272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33828))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-532,999\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -532, 999\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1456^1716 \\pmod{2230}$.", + "Output Answer": [ + "$1156$" + ], + "Output Program": [ + "print(pow(1456, 1716, 2230))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $85430$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 8543^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(85430))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{838,421,332\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 838, 421, 332\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3456}{2735}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10466209}-1728}{2735}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3456/2735)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $4622$.", + "Output Answer": [ + "$\\{3,11,37,51,53,57,75,87,93,107\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(4622):\n if len(roots) == 10: break\n if gcd(a, 4622) == 1 and is_primitive_root(a, 4622):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1554^1425 \\pmod{1764}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(1554, 1425, 1764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $620^m \\equiv 1 \\pmod{719}$.", + "Output Answer": [ + "$359$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(620, 719))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44681", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44681))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 1 \\pmod{18}$\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 3 \\pmod{4}$", + "Output Answer": [ + "$1675$" + ], + "Output Program": [ + "constraints = (3, 11), (1, 18), (20, 5), (3, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 11), (1, 18), (20, 5), (3, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58130 \\pmod{87}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(58130 % 87)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1658^1547 \\pmod{2459}$.", + "Output Answer": [ + "$632$" + ], + "Output Program": [ + "print(pow(1658, 1547, 2459))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11219}{1943}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{140966957}-11219}{3886}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11219/1943)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $30^1833 \\pmod{2227}$.", + "Output Answer": [ + "$1645$" + ], + "Output Program": [ + "print(pow(30, 1833, 2227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n70605", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70605))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1080^1180 \\pmod{1937}$.", + "Output Answer": [ + "$703$" + ], + "Output Program": [ + "print(pow(1080, 1180, 1937))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n30057", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(30057))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2430$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2430 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1656$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1656 % 6 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(551)$.", + "Output Answer": [ + "$504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(551))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-221,-885\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -221, -885\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{9}$\n$x \\equiv 15 \\pmod{12}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "constraints = (3, 9), (15, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 9), (15, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-451,-204\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -451, -204\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $893^1598 \\pmod{1968}$.", + "Output Answer": [ + "$409$" + ], + "Output Program": [ + "print(pow(893, 1598, 1968))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $473^m \\equiv 1 \\pmod{755}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(473, 755))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2062^83 \\pmod{2702}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "print(pow(2062, 83, 2702))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $245$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(245 % 5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $773_8$ to base 10.", + "Output Answer": [ + "$507$" + ], + "Output Program": [ + "n = '773'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1580^949 \\pmod{1924}$.", + "Output Answer": [ + "$1580$" + ], + "Output Program": [ + "print(pow(1580, 949, 1924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $22109$.", + "Output Answer": [ + "$22109^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(22109))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $129_{16}$ to base 10.", + "Output Answer": [ + "$297$" + ], + "Output Program": [ + "n = '129'.strip('.')\nbase = 16\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $37077$.", + "Output Answer": [ + "$3^1\\cdot 17^1\\cdot 727^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37077))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $77x \\equiv 1 \\pmod{1528}$.", + "Output Answer": [ + "$893$" + ], + "Output Program": [ + "print(pow(77, -1, 1528))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-603,198\\}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "import math\n\nvalues = -603, 198\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1167^799 \\pmod{2511}$.", + "Output Answer": [ + "$567$" + ], + "Output Program": [ + "print(pow(1167, 799, 2511))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{9}$\n$x \\equiv 15 \\pmod{14}$", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 9), (15, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 9), (15, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 9), (15, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4561}{14060}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{811537121}-4561}{28120}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4561/14060)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $789x \\equiv 1 \\pmod{1045}$.", + "Output Answer": [ + "$249$" + ], + "Output Program": [ + "print(pow(789, -1, 1045))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34126)$.", + "Output Answer": [ + "$16800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34126))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23552)$.", + "Output Answer": [ + "$11264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23552))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{799,615\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 799, 615\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33040)$.", + "Output Answer": [ + "$11136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33040))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{540,25\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 540, 25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $185^m \\equiv 1 \\pmod{249}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(185, 249))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $201001_3$ to base 10.", + "Output Answer": [ + "$514$" + ], + "Output Program": [ + "n = '201001'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45680 \\pmod{96}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "print(45680 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $906x \\equiv 1 \\pmod{2455}$.", + "Output Answer": [ + "$2371$" + ], + "Output Program": [ + "print(pow(906, -1, 2455))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{359,-111,420\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 359, -111, 420\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18122)$.", + "Output Answer": [ + "$7680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18122))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1602^1162 \\pmod{1624}$.", + "Output Answer": [ + "$1016$" + ], + "Output Program": [ + "print(pow(1602, 1162, 1624))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1260^1899 \\pmod{2401}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(1260, 1899, 2401))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{10}$\n$x \\equiv 11 \\pmod{3}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 10), (11, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 10), (11, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 10), (11, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{19,-488,-31\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 19, -488, -31\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{3}$\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$154$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 3), (10, 8), (11, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 3), (10, 8), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 3), (10, 8), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $78430$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(78430 % -46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-58,39,5\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -58, 39, 5\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $463x \\equiv 1 \\pmod{914}$.", + "Output Answer": [ + "$381$" + ], + "Output Program": [ + "print(pow(463, -1, 914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2173^1957 \\pmod{2772}$.", + "Output Answer": [ + "$1669$" + ], + "Output Program": [ + "print(pow(2173, 1957, 2772))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5974$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5974 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $159^m \\equiv 1 \\pmod{379}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(159, 379))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{144,949\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 144, 949\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $44940$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(44940 % -30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2910$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2910 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13796)$.", + "Output Answer": [ + "$6896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13796))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12043 \\pmod{60}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(12043 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76206 \\pmod{44}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(76206 % 44)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $38113$.", + "Output Answer": [ + "$\\{7,14,19,21,28,38,41,42,47,55\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(38113):\n if len(roots) == 10: break\n if gcd(a, 38113) == 1 and is_primitive_root(a, 38113):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57902 \\pmod{65}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(57902 % 65)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $59x \\equiv 1 \\pmod{411}$.", + "Output Answer": [ + "$209$" + ], + "Output Program": [ + "print(pow(59, -1, 411))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16202}{3049}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{74922602}-8101}{3049}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16202/3049)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8275)$.", + "Output Answer": [ + "$6600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8275))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-585,121,159\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -585, 121, 159\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $735x \\equiv 1 \\pmod{2042}$.", + "Output Answer": [ + "$1353$" + ], + "Output Program": [ + "print(pow(735, -1, 2042))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2119^56 \\pmod{2649}$.", + "Output Answer": [ + "$1345$" + ], + "Output Program": [ + "print(pow(2119, 56, 2649))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{13}$\n$x \\equiv 4 \\pmod{20}$", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 13), (4, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (20, 13), (4, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 13), (4, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1654 \\pmod{38}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(1654 % 38)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $280x \\equiv 1 \\pmod{1369}$.", + "Output Answer": [ + "$1325$" + ], + "Output Program": [ + "print(pow(280, -1, 1369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n95921", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(95921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{10}$\n$x \\equiv 8 \\pmod{9}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 10), (8, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 10), (8, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 10), (8, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39851 \\pmod{76}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(39851 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $64740$.", + "Output Answer": [ + "$2^2\\cdot 3^1\\cdot 5^1\\cdot 13^1\\cdot 83^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(64740))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24329)$.", + "Output Answer": [ + "$24328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24329))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $5977$.", + "Output Answer": [ + "$43^1\\cdot 139^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(5977))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $724^326 \\pmod{1422}$.", + "Output Answer": [ + "$952$" + ], + "Output Program": [ + "print(pow(724, 326, 1422))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97701 \\pmod{8}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(97701 % 8)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-421,593\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -421, 593\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{344,841,-609\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 344, 841, -609\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 0 \\pmod{7}$", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 5), (0, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 5), (0, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 5), (0, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3294}{2011}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6756730}-1647}{2011}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3294/2011)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-130,-914,-472\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -130, -914, -472\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23658 \\pmod{31}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(23658 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $248^m \\equiv 1 \\pmod{603}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(248, 603))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10662)$.", + "Output Answer": [ + "$3552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10662))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $928$ to base $12$.", + "Output Answer": [ + "$654_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 928\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{794}{783}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{783} \\left(\\sqrt{770698}-397\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(794/783)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-141,89,822\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -141, 89, 822\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1629}{4219}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{73853485}-1629}{8438}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1629/4219)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14380}{5319}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{79987861}-7190}{5319}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14380/5319)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22793 \\pmod{65}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(22793 % 65)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 8 \\pmod{9}$\n$x \\equiv 20 \\pmod{12}$", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "constraints = (11, 11), (8, 9), (20, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 11), (8, 9), (20, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n12487", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12487))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{20}$\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 7 \\pmod{9}$", + "Output Answer": [ + "$5668$" + ], + "Output Program": [ + "constraints = (8, 20), (3, 11), (19, 7), (7, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 20), (3, 11), (19, 7), (7, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 20), (3, 11), (19, 7), (7, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28780)$.", + "Output Answer": [ + "$11504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99844 \\pmod{84}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(99844 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9916}{8941}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{104523245}-4958}{8941}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9916/8941)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1861}{5418}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{120882217}-1861}{10836}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1861/5418)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $548^2178 \\pmod{2537}$.", + "Output Answer": [ + "$2376$" + ], + "Output Program": [ + "print(pow(548, 2178, 2537))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $167^1955 \\pmod{2714}$.", + "Output Answer": [ + "$317$" + ], + "Output Program": [ + "print(pow(167, 1955, 2714))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{403,147,526\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 403, 147, 526\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20808)$.", + "Output Answer": [ + "$6528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20808))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $852^86 \\pmod{1976}$.", + "Output Answer": [ + "$1752$" + ], + "Output Program": [ + "print(pow(852, 86, 1976))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42974)$.", + "Output Answer": [ + "$21486$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71409", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71409))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $106x \\equiv 1 \\pmod{227}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(pow(106, -1, 227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $475x \\equiv 1 \\pmod{529}$.", + "Output Answer": [ + "$480$" + ], + "Output Program": [ + "print(pow(475, -1, 529))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $89x \\equiv 1 \\pmod{299}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "print(pow(89, -1, 299))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{415,130\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 415, 130\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13301}{26202}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2923095817}-13301}{52404}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13301/26202)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-5070$ is divisible by $13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5070 % 13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{125}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 125))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{34322}{27747}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1064395930}-17161}{27747}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34322/27747)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $77189$.", + "Output Answer": [ + "$7^1\\cdot 11027^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(77189))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $49x \\equiv 1 \\pmod{1094}$.", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "print(pow(49, -1, 1094))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71423 \\pmod{37}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(71423 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{134,981\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 134, 981\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-397,91\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -397, 91\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $393^m \\equiv 1 \\pmod{748}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(393, 748))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $32411$.", + "Output Answer": [ + "$\\{2,7,8,11,18,19,21,23,24,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(32411):\n if len(roots) == 10: break\n if gcd(a, 32411) == 1 and is_primitive_root(a, 32411):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46819 \\pmod{88}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(46819 % 88)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{16}$\n$x \\equiv 6 \\pmod{7}$\n$x \\equiv 13 \\pmod{2}$", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "constraints = (11, 16), (6, 7), (13, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 16), (6, 7), (13, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $237x \\equiv 1 \\pmod{1066}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(pow(237, -1, 1066))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n59263", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59263))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $323x \\equiv 1 \\pmod{1798}$.", + "Output Answer": [ + "$167$" + ], + "Output Program": [ + "print(pow(323, -1, 1798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $761x \\equiv 1 \\pmod{1174}$.", + "Output Answer": [ + "$307$" + ], + "Output Program": [ + "print(pow(761, -1, 1174))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $72^m \\equiv 1 \\pmod{185}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(72, 185))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9596}{14559}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{234985285}-4798}{14559}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9596/14559)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{554,444\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 554, 444\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $267x \\equiv 1 \\pmod{2086}$.", + "Output Answer": [ + "$1961$" + ], + "Output Program": [ + "print(pow(267, -1, 2086))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1565$ to base $7$.", + "Output Answer": [ + "$4364_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1565\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3997}{9589}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{383771693}-3997}{19178}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3997/9589)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1593^1800 \\pmod{2903}$.", + "Output Answer": [ + "$1399$" + ], + "Output Program": [ + "print(pow(1593, 1800, 2903))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10747}{14337}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{937696285}-10747}{28674}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10747/14337)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1284}{647}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{647} \\left(\\sqrt{830773}-642\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1284/647)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{14}$\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 19 \\pmod{10}$", + "Output Answer": [ + "$1699$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 14), (16, 3), (16, 11), (19, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 14), (16, 3), (16, 11), (19, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-22533$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-22533 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{759}{455}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{910} \\left(\\sqrt{1404181}-759\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(759/455)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n1089", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1089))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45733 \\pmod{59}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(45733 % 59)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1999x \\equiv 1 \\pmod{2252}$.", + "Output Answer": [ + "$1531$" + ], + "Output Program": [ + "print(pow(1999, -1, 2252))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $137x \\equiv 1 \\pmod{445}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(137, -1, 445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $36345$.", + "Output Answer": [ + "$3^1\\cdot 5^1\\cdot 2423^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(36345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $218^m \\equiv 1 \\pmod{585}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(218, 585))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1228x \\equiv 1 \\pmod{2003}$.", + "Output Answer": [ + "$367$" + ], + "Output Program": [ + "print(pow(1228, -1, 2003))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-992,62,-523\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -992, 62, -523\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $49^m \\equiv 1 \\pmod{118}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(49, 118))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $63514$.", + "Output Answer": [ + "$2^1\\cdot 11^1\\cdot 2887^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(63514))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $285x \\equiv 1 \\pmod{356}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(pow(285, -1, 356))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40651)$.", + "Output Answer": [ + "$36192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40651))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35731 \\pmod{9}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(35731 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(295)$.", + "Output Answer": [ + "$232$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39603 \\pmod{14}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(39603 % 14)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $173^304 \\pmod{2081}$.", + "Output Answer": [ + "$635$" + ], + "Output Program": [ + "print(pow(173, 304, 2081))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28164)$.", + "Output Answer": [ + "$9384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28164))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6079}{7340}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{252456641}-6079}{14680}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6079/7340)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $39^339 \\pmod{2763}$.", + "Output Answer": [ + "$1503$" + ], + "Output Program": [ + "print(pow(39, 339, 2763))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 8 \\pmod{13}$", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "constraints = (3, 3), (8, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 3), (8, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 3), (8, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12056}{16305}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{302189809}-6028}{16305}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12056/16305)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27030)$.", + "Output Answer": [ + "$6656$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27030))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-582,-512\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -582, -512\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 1 \\pmod{7}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 2), (1, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 2), (1, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 2), (1, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54925 \\pmod{49}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(54925 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16928 \\pmod{70}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "print(16928 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 700 \\pmod{81}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(700 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{10}$\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$195$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 10), (0, 13), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 10), (0, 13), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 10), (0, 13), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $28525$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(28525 % 25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3071}{5490}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{129991441}-3071}{10980}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3071/5490)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7805$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7805 % -35 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $703^1374 \\pmod{1964}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(pow(703, 1374, 1964))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $34366$.", + "Output Answer": [ + "$\\{5,11,15,29,31,33,35,37,45,47\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(34366):\n if len(roots) == 10: break\n if gcd(a, 34366) == 1 and is_primitive_root(a, 34366):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $577x \\equiv 1 \\pmod{834}$.", + "Output Answer": [ + "$331$" + ], + "Output Program": [ + "print(pow(577, -1, 834))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 731 \\pmod{61}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(731 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-108,-32\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -108, -32\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $341x \\equiv 1 \\pmod{626}$.", + "Output Answer": [ + "$123$" + ], + "Output Program": [ + "print(pow(341, -1, 626))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{821,513,92\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 821, 513, 92\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{221}{147}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{294} \\left(\\sqrt{135277}-221\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(221/147)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{15364}{3471}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{71060965}-7682}{3471}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15364/3471)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $499^1948 \\pmod{1202}$.", + "Output Answer": [ + "$385$" + ], + "Output Program": [ + "print(pow(499, 1948, 1202))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{19,-309,266\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 19, -309, 266\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $868x \\equiv 1 \\pmod{2395}$.", + "Output Answer": [ + "$1272$" + ], + "Output Program": [ + "print(pow(868, -1, 2395))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n95237", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(95237))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n38503", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(38503))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(873)$.", + "Output Answer": [ + "$576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(873))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38720)$.", + "Output Answer": [ + "$14080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38720))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $244$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(244 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-158$ is divisible by $-2$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-158 % -2 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5302 \\pmod{34}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(5302 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{564,178\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 564, 178\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2319^1095 \\pmod{2882}$.", + "Output Answer": [ + "$155$" + ], + "Output Program": [ + "print(pow(2319, 1095, 2882))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 13 \\pmod{14}$", + "Output Answer": [ + "$167$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 17), (13, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 17), (13, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (13, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-612$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-612 % -41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n89503", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89503))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $887^372 \\pmod{2446}$.", + "Output Answer": [ + "$1397$" + ], + "Output Program": [ + "print(pow(887, 372, 2446))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1079}{1512}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10308817}-1079}{3024}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1079/1512)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $846^2033 \\pmod{1031}$.", + "Output Answer": [ + "$913$" + ], + "Output Program": [ + "print(pow(846, 2033, 1031))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $36640$.", + "Output Answer": [ + "$2^5\\cdot 5^1\\cdot 229^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(36640))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-594,878\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -594, 878\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-86,11,345\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -86, 11, 345\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1735$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1735 % 25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94182 \\pmod{61}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(94182 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1010x \\equiv 1 \\pmod{1637}$.", + "Output Answer": [ + "$530$" + ], + "Output Program": [ + "print(pow(1010, -1, 1637))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $746^2293 \\pmod{2787}$.", + "Output Answer": [ + "$1580$" + ], + "Output Program": [ + "print(pow(746, 2293, 2787))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $240^39 \\pmod{824}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(pow(240, 39, 824))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n82939", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82939))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1207x \\equiv 1 \\pmod{2054}$.", + "Output Answer": [ + "$97$" + ], + "Output Program": [ + "print(pow(1207, -1, 2054))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16603 \\pmod{69}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(16603 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{190,23,403\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 190, 23, 403\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.78_{20}$ to base 10.", + "Output Answer": [ + "$0.37$" + ], + "Output Program": [ + "n = '0.78'.strip('.')\nbase = 20\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $616^82 \\pmod{1367}$.", + "Output Answer": [ + "$486$" + ], + "Output Program": [ + "print(pow(616, 82, 1367))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1547}{16206}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1052930953}-1547}{32412}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1547/16206)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11096}{13413}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{210688873}-5548}{13413}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11096/13413)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $226^m \\equiv 1 \\pmod{379}$.", + "Output Answer": [ + "$189$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(226, 379))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9716 \\pmod{12}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(9716 % 12)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-37440$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-37440 % -30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73133 \\pmod{12}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(73133 % 12)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{826,-436,95\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 826, -436, 95\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86853 \\pmod{34}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(86853 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4158$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-4158 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{14}$\n$x \\equiv 20 \\pmod{16}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "constraints = (20, 14), (20, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 14), (20, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7722}{5153}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{41460730}-3861}{5153}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7722/5153)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1091$ is divisible by $38$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1091 % 38 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1481$ to base $31$.", + "Output Answer": [ + "$\\text{1go}_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1481\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1120^2172 \\pmod{1752}$.", + "Output Answer": [ + "$592$" + ], + "Output Program": [ + "print(pow(1120, 2172, 1752))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $64x \\equiv 1 \\pmod{291}$.", + "Output Answer": [ + "$241$" + ], + "Output Program": [ + "print(pow(64, -1, 291))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{111}{412}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{824} \\left(\\sqrt{691297}-111\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(111/412)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-467,21,-745\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -467, 21, -745\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{16}$\n$x \\equiv 9 \\pmod{12}$", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "constraints = (1, 16), (9, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 16), (9, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{16}$\n$x \\equiv 6 \\pmod{3}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 16), (6, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 16), (6, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 16), (6, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{973,-298\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 973, -298\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $48820$.", + "Output Answer": [ + "$2^2\\cdot 5^1\\cdot 2441^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(48820))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $246x \\equiv 1 \\pmod{611}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(pow(246, -1, 611))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75982 \\pmod{42}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(75982 % 42)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{7}$\n$x \\equiv 20 \\pmod{5}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "constraints = (3, 7), (20, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 7), (20, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (3, 7), (20, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $34425$ is divisible by $27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(34425 % 27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $535x \\equiv 1 \\pmod{1536}$.", + "Output Answer": [ + "$1447$" + ], + "Output Program": [ + "print(pow(535, -1, 1536))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.47$ to base $30$.", + "Output Answer": [ + "$\\text{0.e3}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.47\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1387^960 \\pmod{1558}$.", + "Output Answer": [ + "$247$" + ], + "Output Program": [ + "print(pow(1387, 960, 1558))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $195^m \\equiv 1 \\pmod{374}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(195, 374))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{889,7,638\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 889, 7, 638\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38568)$.", + "Output Answer": [ + "$12848$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38568))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-86$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-86 % 19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75215 \\pmod{76}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(75215 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52122 \\pmod{33}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(52122 % 33)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6703 \\pmod{85}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(6703 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $2782$.", + "Output Answer": [ + "$2^1\\cdot 13^1\\cdot 107^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(2782))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n37445", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(37445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-239,-53\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -239, -53\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21381 \\pmod{66}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(21381 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3673}{7659}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{1468237}-3673}{15318}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3673/7659)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $4$.", + "Output Answer": [ + "$\\{3\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(4):\n if len(roots) == 10: break\n if gcd(a, 4) == 1 and is_primitive_root(a, 4):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11190$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-11190 % 15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{315}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 315))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-5356$ is divisible by $13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5356 % 13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $25978$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(25978 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-681,371,520\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -681, 371, 520\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20076)$.", + "Output Answer": [ + "$5712$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20076))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1601)$.", + "Output Answer": [ + "$1600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1601))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $213^m \\equiv 1 \\pmod{391}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(213, 391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5058)$.", + "Output Answer": [ + "$1680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5058))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=10$ $29$-gonal number.\n", + "Output Answer": [ + "$3277$" + ], + "Output Program": [ + "n = 10\nk = 29\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $52321$.", + "Output Answer": [ + "$\\{17,19,21,34,35,38,42,43,47,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(52321):\n if len(roots) == 10: break\n if gcd(a, 52321) == 1 and is_primitive_root(a, 52321):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $323x \\equiv 1 \\pmod{338}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(pow(323, -1, 338))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29619 \\pmod{21}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(29619 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18722}{2615}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{94466546}-9361}{2615}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18722/2615)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-482,320\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -482, 320\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $143^m \\equiv 1 \\pmod{967}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(143, 967))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{13}$\n$x \\equiv 2 \\pmod{11}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "constraints = (13, 13), (2, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 13), (2, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 13), (2, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-414$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-414 % -12 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1716$ to base $4$.", + "Output Answer": [ + "$122310_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1716\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n31791", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31791))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $228^1431 \\pmod{1836}$.", + "Output Answer": [ + "$216$" + ], + "Output Program": [ + "print(pow(228, 1431, 1836))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73933 \\pmod{84}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(73933 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20890)$.", + "Output Answer": [ + "$8352$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20890))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-663,929\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -663, 929\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n3881", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(3881))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-531$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-531 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $275^m \\equiv 1 \\pmod{532}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(275, 532))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1566^1782 \\pmod{2411}$.", + "Output Answer": [ + "$2120$" + ], + "Output Program": [ + "print(pow(1566, 1782, 2411))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $209x \\equiv 1 \\pmod{1048}$.", + "Output Answer": [ + "$697$" + ], + "Output Program": [ + "print(pow(209, -1, 1048))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12952}{15157}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{10866929}-6476}{15157}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12952/15157)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $174^m \\equiv 1 \\pmod{851}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(174, 851))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2104^631 \\pmod{2121}$.", + "Output Answer": [ + "$2104$" + ], + "Output Program": [ + "print(pow(2104, 631, 2121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17693 \\pmod{41}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(17693 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $955$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(955 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{900,224,869\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 900, 224, 869\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $537x \\equiv 1 \\pmod{1898}$.", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "print(pow(537, -1, 1898))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $406^m \\equiv 1 \\pmod{699}$.", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(406, 699))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43202 \\pmod{36}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(43202 % 36)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{683,880,-197\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 683, 880, -197\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{104}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 104))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1060)$.", + "Output Answer": [ + "$416$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31901 \\pmod{98}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(31901 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18542}{319}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{319} \\left(\\sqrt{86053202}-9271\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18542/319)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4617}{4657}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{108067285}-4617}{9314}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4617/4657)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{29,-100,609\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 29, -100, 609\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{240,809,409\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 240, 809, 409\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $843^322 \\pmod{1445}$.", + "Output Answer": [ + "$1069$" + ], + "Output Program": [ + "print(pow(843, 322, 1445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6766 \\pmod{13}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(6766 % 13)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n41543", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(41543))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1825^2068 \\pmod{1960}$.", + "Output Answer": [ + "$345$" + ], + "Output Program": [ + "print(pow(1825, 2068, 1960))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24148)$.", + "Output Answer": [ + "$12072$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24148))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-886,967\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -886, 967\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1168$ to base $7$.", + "Output Answer": [ + "$3256_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1168\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.87$ to base $19$.", + "Output Answer": [ + "$\\text{0.ga165}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.87\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $20x \\equiv 1 \\pmod{71}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(pow(20, -1, 71))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{18}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "constraints = (18, 18), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 18), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 18), (3, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 5 \\pmod{9}$\n$x \\equiv 5 \\pmod{2}$", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "constraints = (5, 4), (7, 7), (5, 9), (5, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 4), (7, 7), (5, 9), (5, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3336}{6151}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1624681}-1668}{6151}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3336/6151)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20590)$.", + "Output Answer": [ + "$7840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20590))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45014 \\pmod{9}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(45014 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6341)$.", + "Output Answer": [ + "$5952$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6341))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1073x \\equiv 1 \\pmod{2343}$.", + "Output Answer": [ + "$1784$" + ], + "Output Program": [ + "print(pow(1073, -1, 2343))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $543$ to base $5$.", + "Output Answer": [ + "$4133_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 543\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4699)$.", + "Output Answer": [ + "$4536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4699))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1999^1962 \\pmod{2017}$.", + "Output Answer": [ + "$995$" + ], + "Output Program": [ + "print(pow(1999, 1962, 2017))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-5217$ is divisible by $-47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5217 % -47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $257x \\equiv 1 \\pmod{978}$.", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "print(pow(257, -1, 978))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-805,-811\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -805, -811\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1115x \\equiv 1 \\pmod{1147}$.", + "Output Answer": [ + "$681$" + ], + "Output Program": [ + "print(pow(1115, -1, 1147))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46870)$.", + "Output Answer": [ + "$18144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46870))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$462$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 4), (7, 7), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 4), (7, 7), (3, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 4), (7, 7), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $78$ to base $20$.", + "Output Answer": [ + "$\\text{3i}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 78\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 0 \\pmod{16}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 11), (0, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 11), (0, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 11), (0, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-332$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-332 % -18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $64102$.", + "Output Answer": [ + "$\\{13,17,19,23,31,39,41,43,51,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(64102):\n if len(roots) == 10: break\n if gcd(a, 64102) == 1 and is_primitive_root(a, 64102):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-23199$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-23199 % 33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.344$ to base $33$.", + "Output Answer": [ + "$\\text{0.bbkb}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.344\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11125}{18543}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1499137021}-11125}{37086}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11125/18543)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $543x \\equiv 1 \\pmod{680}$.", + "Output Answer": [ + "$407$" + ], + "Output Program": [ + "print(pow(543, -1, 680))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n26307", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26307))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41846)$.", + "Output Answer": [ + "$17640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41846))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n69405", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(69405))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $418^362 \\pmod{2582}$.", + "Output Answer": [ + "$990$" + ], + "Output Program": [ + "print(pow(418, 362, 2582))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1661x \\equiv 1 \\pmod{1680}$.", + "Output Answer": [ + "$1061$" + ], + "Output Program": [ + "print(pow(1661, -1, 1680))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{8}$\n$x \\equiv 11 \\pmod{19}$", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 8), (11, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 8), (11, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 8), (11, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{18}$\n$x \\equiv 11 \\pmod{4}$\n$x \\equiv 2 \\pmod{19}$", + "Output Answer": [ + "$287$" + ], + "Output Program": [ + "constraints = (17, 18), (11, 4), (2, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 18), (11, 4), (2, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11531)$.", + "Output Answer": [ + "$10632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11531))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{840,444\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 840, 444\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1056^535 \\pmod{1443}$.", + "Output Answer": [ + "$627$" + ], + "Output Program": [ + "print(pow(1056, 535, 1443))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1945^1869 \\pmod{2247}$.", + "Output Answer": [ + "$1420$" + ], + "Output Program": [ + "print(pow(1945, 1869, 2247))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $164^m \\equiv 1 \\pmod{167}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(164, 167))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{101,252,396\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 101, 252, 396\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{878,212\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 878, 212\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4816}{4497}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{26021473}-2408}{4497}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4816/4497)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $209^m \\equiv 1 \\pmod{240}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(209, 240))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $931x \\equiv 1 \\pmod{1010}$.", + "Output Answer": [ + "$831$" + ], + "Output Program": [ + "print(pow(931, -1, 1010))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $6084$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(6084 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n95103", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(95103))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{449,-225\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 449, -225\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1697_{11}$ to base 10.", + "Output Answer": [ + "$2163$" + ], + "Output Program": [ + "n = '1697'.strip('.')\nbase = 11\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{751,833\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 751, 833\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6252)$.", + "Output Answer": [ + "$2080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6252))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $311^m \\equiv 1 \\pmod{548}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(311, 548))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $678^1385 \\pmod{1499}$.", + "Output Answer": [ + "$912$" + ], + "Output Program": [ + "print(pow(678, 1385, 1499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 3 \\pmod{14}$", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 11), (3, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (3, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 11), (3, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{7}$\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 19 \\pmod{11}$\n$x \\equiv 1 \\pmod{3}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 7), (12, 7), (19, 11), (1, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 7), (12, 7), (19, 11), (1, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1303}{406}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{812} \\left(\\sqrt{2357153}-1303\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1303/406)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $177^1589 \\pmod{1687}$.", + "Output Answer": [ + "$900$" + ], + "Output Program": [ + "print(pow(177, 1589, 1687))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71318 \\pmod{30}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(71318 % 30)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3210}{1693}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5442274}-1605}{1693}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3210/1693)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $7015$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7015 % -23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17493}{569}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{307300093}-17493}{1138}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17493/569)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97959", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97959))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $116x \\equiv 1 \\pmod{567}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(pow(116, -1, 567))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{12}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 12), (19, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 12), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 12), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30507 \\pmod{23}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(30507 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9355}{12246}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{687374089}-9355}{24492}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9355/12246)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-610,200\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -610, 200\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{284,182\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 284, 182\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $764^m \\equiv 1 \\pmod{861}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(764, 861))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $21295$.", + "Output Answer": [ + "$5^1\\cdot 4259^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(21295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $43^m \\equiv 1 \\pmod{528}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(43, 528))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1036^1172 \\pmod{1470}$.", + "Output Answer": [ + "$196$" + ], + "Output Program": [ + "print(pow(1036, 1172, 1470))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63623 \\pmod{60}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(63623 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-727,334,733\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -727, 334, 733\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63480 \\pmod{58}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(63480 % 58)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n12575", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12575))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $49^m \\equiv 1 \\pmod{235}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(49, 235))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-337,233,815\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -337, 233, 815\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33222)$.", + "Output Answer": [ + "$9408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33222))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n27397", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(27397))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-33$ is divisible by $-2$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-33 % -2 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13930)$.", + "Output Answer": [ + "$4752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13930))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16995}{8057}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{3245509}-16995}{16114}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16995/8057)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $4610$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4610 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2032^1662 \\pmod{2947}$.", + "Output Answer": [ + "$1751$" + ], + "Output Program": [ + "print(pow(2032, 1662, 2947))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.127$ to base $16$.", + "Output Answer": [ + "$0.20831_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.127\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n7953", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7953))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $21993$.", + "Output Answer": [ + "$3^1\\cdot 7331^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(21993))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5047)$.", + "Output Answer": [ + "$4284$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5047))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $853^m \\equiv 1 \\pmod{944}$.", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(853, 944))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $42241$.", + "Output Answer": [ + "$53^1\\cdot 797^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(42241))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-923,-625,493\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -923, -625, 493\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1389^2196 \\pmod{1611}$.", + "Output Answer": [ + "$909$" + ], + "Output Program": [ + "print(pow(1389, 2196, 1611))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15538 \\pmod{67}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(15538 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16088)$.", + "Output Answer": [ + "$8040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16088))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21043 \\pmod{28}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(21043 % 28)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43652)$.", + "Output Answer": [ + "$18696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43652))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31975 \\pmod{89}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(31975 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1652x \\equiv 1 \\pmod{1755}$.", + "Output Answer": [ + "$443$" + ], + "Output Program": [ + "print(pow(1652, -1, 1755))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{3}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 3), (11, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 3), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 3), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{875,864,-459\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 875, 864, -459\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{546,129\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 546, 129\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5766}{6629}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{52255330}-2883}{6629}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5766/6629)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{29159}{25894}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{141289769}-29159}{51788}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29159/25894)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-54$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-54 % -12 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16791}{21253}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2088697717}-16791}{42506}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16791/21253)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $97^m \\equiv 1 \\pmod{510}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(97, 510))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12834 \\pmod{8}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(12834 % 8)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5254}{4493}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{27088178}-2627}{4493}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5254/4493)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4071)$.", + "Output Answer": [ + "$2552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4071))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $12^m \\equiv 1 \\pmod{13}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(12, 13))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11136$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-11136 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.55$ to base $2$.", + "Output Answer": [ + "$0.10001100110011001101_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.55\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-26364$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-26364 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $711x \\equiv 1 \\pmod{1681}$.", + "Output Answer": [ + "$331$" + ], + "Output Program": [ + "print(pow(711, -1, 1681))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $21756$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(21756 % 42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $256^340 \\pmod{2677}$.", + "Output Answer": [ + "$170$" + ], + "Output Program": [ + "print(pow(256, 340, 2677))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n1033", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1033))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24431)$.", + "Output Answer": [ + "$22200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24431))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-508$ is divisible by $23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-508 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31344)$.", + "Output Answer": [ + "$10432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31344))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $34919$.", + "Output Answer": [ + "$\\{19,22,33,38,41,44,53,57,58,66\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(34919):\n if len(roots) == 10: break\n if gcd(a, 34919) == 1 and is_primitive_root(a, 34919):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.68$ to base $7$.", + "Output Answer": [ + "$0.4521452_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.68\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-473,-14,213\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -473, -14, 213\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12594)$.", + "Output Answer": [ + "$4196$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12594))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{26246}{45723}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2262805858}-13123}{45723}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26246/45723)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{175,-995\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 175, -995\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51441 \\pmod{66}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(51441 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-509,28\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -509, 28\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{21469}{8065}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{721094861}-21469}{16130}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21469/8065)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $95$ is divisible by $6$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(95 % 6 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $709^447 \\pmod{2695}$.", + "Output Answer": [ + "$1499$" + ], + "Output Program": [ + "print(pow(709, 447, 2695))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $66477$.", + "Output Answer": [ + "$3^1\\cdot 22159^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(66477))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.1353135_7$ to base 10.", + "Output Answer": [ + "$0.22$" + ], + "Output Program": [ + "n = '0.1353135'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{5}$\n$x \\equiv 16 \\pmod{11}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "constraints = (16, 5), (16, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 5), (16, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 5), (16, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{2}$\n$x \\equiv 8 \\pmod{15}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "constraints = (2, 2), (8, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 2), (8, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 2), (8, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8573$.", + "Output Answer": [ + "$\\{2,3,5,7,8,12,13,17,18,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8573):\n if len(roots) == 10: break\n if gcd(a, 8573) == 1 and is_primitive_root(a, 8573):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4304)$.", + "Output Answer": [ + "$2144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4304))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27}{1966}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{15461353}-27}{3932}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27/1966)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{71,-916\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 71, -916\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $11883$.", + "Output Answer": [ + "$3^1\\cdot 17^1\\cdot 233^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(11883))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{28018}{25871}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{865560722}-14009}{25871}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(28018/25871)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-906,-556\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -906, -556\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 14 \\pmod{17}$", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "constraints = (14, 13), (14, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 13), (14, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 13), (14, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15820)$.", + "Output Answer": [ + "$5376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15820))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $599x \\equiv 1 \\pmod{1596}$.", + "Output Answer": [ + "$1199$" + ], + "Output Program": [ + "print(pow(599, -1, 1596))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $569^m \\equiv 1 \\pmod{756}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(569, 756))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1371^2286 \\pmod{1567}$.", + "Output Answer": [ + "$111$" + ], + "Output Program": [ + "print(pow(1371, 2286, 1567))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $452^2075 \\pmod{1590}$.", + "Output Answer": [ + "$278$" + ], + "Output Program": [ + "print(pow(452, 2075, 1590))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33053)$.", + "Output Answer": [ + "$33052$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33053))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $775x \\equiv 1 \\pmod{1946}$.", + "Output Answer": [ + "$801$" + ], + "Output Program": [ + "print(pow(775, -1, 1946))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $427$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(427 % -16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1209x \\equiv 1 \\pmod{1786}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(pow(1209, -1, 1786))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $445^m \\equiv 1 \\pmod{608}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(445, 608))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{904}{1237}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1734473}-452}{1237}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(904/1237)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{6}$\n$x \\equiv 20 \\pmod{11}$", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 6), (20, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 6), (20, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 6), (20, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37337)$.", + "Output Answer": [ + "$37336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37337))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{5}$\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 4 \\pmod{8}$", + "Output Answer": [ + "$132$" + ], + "Output Program": [ + "constraints = (17, 5), (6, 6), (6, 14), (4, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 5), (6, 6), (6, 14), (4, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-23184$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-23184 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{63,-758,212\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 63, -758, 212\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-43362$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-43362 % -33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $984$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(984 % -8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 9 \\pmod{11}$", + "Output Answer": [ + "$119$" + ], + "Output Program": [ + "constraints = (14, 15), (9, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 15), (9, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 15), (9, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 1 \\pmod{20}$\n$x \\equiv 15 \\pmod{7}$", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "constraints = (8, 19), (1, 20), (15, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 19), (1, 20), (15, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (1, 20), (15, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{561,379,-936\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 561, 379, -936\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{45,547,-182\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 45, 547, -182\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17142}{11263}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{200317210}-8571}{11263}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17142/11263)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{8}$\n$x \\equiv 5 \\pmod{17}$\n$x \\equiv 19 \\pmod{4}$\n$x \\equiv 1 \\pmod{3}$", + "Output Answer": [ + "$379$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 8), (5, 17), (19, 4), (1, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 8), (5, 17), (19, 4), (1, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{690,236\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 690, 236\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $61673$.", + "Output Answer": [ + "$\\{5,6,7,10,11,12,17,19,20,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(61673):\n if len(roots) == 10: break\n if gcd(a, 61673) == 1 and is_primitive_root(a, 61673):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-29,-227\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -29, -227\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53129 \\pmod{33}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(53129 % 33)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4462}{2861}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{13162682}-2231}{2861}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4462/2861)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41167 \\pmod{9}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(41167 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-14610$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-14610 % -30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-632,46,13\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -632, 46, 13\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21147)$.", + "Output Answer": [ + "$11232$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21147))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $199^m \\equiv 1 \\pmod{280}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(199, 280))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2255^1521 \\pmod{2296}$.", + "Output Answer": [ + "$2255$" + ], + "Output Program": [ + "print(pow(2255, 1521, 2296))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $385^m \\equiv 1 \\pmod{478}$.", + "Output Answer": [ + "$238$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(385, 478))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-277,-219\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -277, -219\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $967^878 \\pmod{2746}$.", + "Output Answer": [ + "$505$" + ], + "Output Program": [ + "print(pow(967, 878, 2746))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1738^2026 \\pmod{2589}$.", + "Output Answer": [ + "$142$" + ], + "Output Program": [ + "print(pow(1738, 2026, 2589))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{1,0,2,-3\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = 1, 0, 2, -3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $6090$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6090 % -21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14221)$.", + "Output Answer": [ + "$14220$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(777)$.", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(777))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.38$ to base $18$.", + "Output Answer": [ + "$\\text{0.6f22g}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.38\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $772x \\equiv 1 \\pmod{1445}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(772, -1, 1445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 15 \\pmod{6}$\n$x \\equiv 9 \\pmod{16}$", + "Output Answer": [ + "$585$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 10), (15, 19), (15, 6), (9, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 10), (15, 19), (15, 6), (9, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $103^m \\equiv 1 \\pmod{822}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(103, 822))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30273 \\pmod{49}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(30273 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $43^m \\equiv 1 \\pmod{115}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(43, 115))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19902)$.", + "Output Answer": [ + "$6360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19902))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $794^1116 \\pmod{2332}$.", + "Output Answer": [ + "$372$" + ], + "Output Program": [ + "print(pow(794, 1116, 2332))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{176,-240\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 176, -240\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{5}$\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 9 \\pmod{13}$", + "Output Answer": [ + "$243$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 5), (19, 7), (9, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 5), (19, 7), (9, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 5), (19, 7), (9, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-2,-3,-4,3\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = -2, -3, -4, 3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $17970$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(17970 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{522}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 522))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12348)$.", + "Output Answer": [ + "$3528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12348))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1705^1795 \\pmod{2274}$.", + "Output Answer": [ + "$499$" + ], + "Output Program": [ + "print(pow(1705, 1795, 2274))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1415^2047 \\pmod{1614}$.", + "Output Answer": [ + "$1097$" + ], + "Output Program": [ + "print(pow(1415, 2047, 1614))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1759}{2228}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{22950017}-1759}{4456}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1759/2228)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2039^712 \\pmod{2676}$.", + "Output Answer": [ + "$925$" + ], + "Output Program": [ + "print(pow(2039, 712, 2676))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1570^1810 \\pmod{2780}$.", + "Output Answer": [ + "$1020$" + ], + "Output Program": [ + "print(pow(1570, 1810, 2780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25258)$.", + "Output Answer": [ + "$12384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25258))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $922x \\equiv 1 \\pmod{1873}$.", + "Output Answer": [ + "$1550$" + ], + "Output Program": [ + "print(pow(922, -1, 1873))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2486^1330 \\pmod{2975}$.", + "Output Answer": [ + "$526$" + ], + "Output Program": [ + "print(pow(2486, 1330, 2975))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{16}$\n$x \\equiv 3 \\pmod{9}$", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "constraints = (7, 16), (3, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 16), (3, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 16), (3, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $379^m \\equiv 1 \\pmod{918}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(379, 918))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-58720$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-58720 % -40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.54$ to base $21$.", + "Output Answer": [ + "$\\text{0.b72jg}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.54\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14785)$.", + "Output Answer": [ + "$11824$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14785))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1305^349 \\pmod{2357}$.", + "Output Answer": [ + "$1640$" + ], + "Output Program": [ + "print(pow(1305, 349, 2357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $412^m \\equiv 1 \\pmod{669}$.", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(412, 669))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $872x \\equiv 1 \\pmod{1665}$.", + "Output Answer": [ + "$548$" + ], + "Output Program": [ + "print(pow(872, -1, 1665))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1154x \\equiv 1 \\pmod{1683}$.", + "Output Answer": [ + "$824$" + ], + "Output Program": [ + "print(pow(1154, -1, 1683))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $308^1060 \\pmod{2094}$.", + "Output Answer": [ + "$1462$" + ], + "Output Program": [ + "print(pow(308, 1060, 2094))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66121 \\pmod{70}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "print(66121 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $58076$.", + "Output Answer": [ + "$2^2\\cdot 14519^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(58076))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n24633", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24633))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50812 \\pmod{83}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(50812 % 83)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10277}{29}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{58} \\left(\\sqrt{105620093}-10277\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10277/29)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $627$ to base $11$.", + "Output Answer": [ + "$520_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 627\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $943^1743 \\pmod{2745}$.", + "Output Answer": [ + "$2737$" + ], + "Output Program": [ + "print(pow(943, 1743, 2745))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $720_{15}$ to base 10.", + "Output Answer": [ + "$1605$" + ], + "Output Program": [ + "n = '720'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $139^m \\equiv 1 \\pmod{365}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(139, 365))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-883,103,570\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -883, 103, 570\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{963,639\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 963, 639\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-963,458,335\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -963, 458, 335\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $521^1196 \\pmod{1912}$.", + "Output Answer": [ + "$425$" + ], + "Output Program": [ + "print(pow(521, 1196, 1912))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $781^989 \\pmod{2605}$.", + "Output Answer": [ + "$1886$" + ], + "Output Program": [ + "print(pow(781, 989, 2605))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $420^m \\equiv 1 \\pmod{923}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(420, 923))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9643)$.", + "Output Answer": [ + "$9642$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9643))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1505^1258 \\pmod{2232}$.", + "Output Answer": [ + "$1609$" + ], + "Output Program": [ + "print(pow(1505, 1258, 2232))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21929 \\pmod{39}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(21929 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24544 \\pmod{63}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(24544 % 63)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68896 \\pmod{84}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(68896 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $836x \\equiv 1 \\pmod{2061}$.", + "Output Answer": [ + "$1457$" + ], + "Output Program": [ + "print(pow(836, -1, 2061))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45694 \\pmod{85}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(45694 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $7675$.", + "Output Answer": [ + "$5^2\\cdot 307^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(7675))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $87x \\equiv 1 \\pmod{128}$.", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "print(pow(87, -1, 128))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $918^253 \\pmod{1951}$.", + "Output Answer": [ + "$1949$" + ], + "Output Program": [ + "print(pow(918, 253, 1951))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-29337$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-29337 % -33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{471}{97}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{194} \\left(\\sqrt{259477}-471\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(471/97)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $4480$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4480 % 20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1171x \\equiv 1 \\pmod{1518}$.", + "Output Answer": [ + "$1483$" + ], + "Output Program": [ + "print(pow(1171, -1, 1518))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1032$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1032 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25066 \\pmod{37}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(25066 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33057)$.", + "Output Answer": [ + "$22032$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33057))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-736,630,145\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -736, 630, 145\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-572,219,623\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -572, 219, 623\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{37080}{8699}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{419404201}-18540}{8699}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37080/8699)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $399x \\equiv 1 \\pmod{1780}$.", + "Output Answer": [ + "$919$" + ], + "Output Program": [ + "print(pow(399, -1, 1780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.73_{15}$ to base 10.", + "Output Answer": [ + "$0.48$" + ], + "Output Program": [ + "n = '0.73'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $46489$.", + "Output Answer": [ + "$\\{29,34,51,57,58,61,67,68,74,76\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(46489):\n if len(roots) == 10: break\n if gcd(a, 46489) == 1 and is_primitive_root(a, 46489):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1105}{359}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{718} \\left(\\sqrt{1736549}-1105\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1105/359)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-11024$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-11024 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20497 \\pmod{37}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(20497 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $544^m \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(544, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3789)$.", + "Output Answer": [ + "$2520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-902,491,-955\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -902, 491, -955\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50297 \\pmod{99}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(50297 % 99)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{37433}{33893}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5996171285}-37433}{67786}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37433/33893)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1913x \\equiv 1 \\pmod{2145}$.", + "Output Answer": [ + "$527$" + ], + "Output Program": [ + "print(pow(1913, -1, 2145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31284)$.", + "Output Answer": [ + "$9360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31284))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2073^845 \\pmod{2936}$.", + "Output Answer": [ + "$2441$" + ], + "Output Program": [ + "print(pow(2073, 845, 2936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $565^542 \\pmod{2619}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(pow(565, 542, 2619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n15451", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(15451))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13079)$.", + "Output Answer": [ + "$11200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13079))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66183 \\pmod{2}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(66183 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62065 \\pmod{50}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(62065 % 50)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $337x \\equiv 1 \\pmod{1552}$.", + "Output Answer": [ + "$1377$" + ], + "Output Program": [ + "print(pow(337, -1, 1552))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{333,732\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 333, 732\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37970 \\pmod{85}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(37970 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 13 \\pmod{5}$", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 11), (13, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 11), (13, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 11), (13, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30730}{17617}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{546441914}-15365}{17617}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30730/17617)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $918^1421 \\pmod{1760}$.", + "Output Answer": [ + "$1248$" + ], + "Output Program": [ + "print(pow(918, 1421, 1760))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $502x \\equiv 1 \\pmod{1499}$.", + "Output Answer": [ + "$857$" + ], + "Output Program": [ + "print(pow(502, -1, 1499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $325x \\equiv 1 \\pmod{817}$.", + "Output Answer": [ + "$181$" + ], + "Output Program": [ + "print(pow(325, -1, 817))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1633^162 \\pmod{2403}$.", + "Output Answer": [ + "$2242$" + ], + "Output Program": [ + "print(pow(1633, 162, 2403))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{8}$\n$x \\equiv 2 \\pmod{3}$\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 8 \\pmod{3}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 8), (2, 3), (19, 7), (8, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 8), (2, 3), (19, 7), (8, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $353x \\equiv 1 \\pmod{540}$.", + "Output Answer": [ + "$257$" + ], + "Output Program": [ + "print(pow(353, -1, 540))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $1154$.", + "Output Answer": [ + "$\\{5,7,13,15,21,39,43,45,55,61\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(1154):\n if len(roots) == 10: break\n if gcd(a, 1154) == 1 and is_primitive_root(a, 1154):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21393)$.", + "Output Answer": [ + "$14256$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21393))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11698}{4783}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{57087890}-5849}{4783}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11698/4783)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $67x \\equiv 1 \\pmod{288}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(pow(67, -1, 288))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.18$ to base $28$.", + "Output Answer": [ + "$\\text{0.513a}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.18\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{12}$\n$x \\equiv 1 \\pmod{2}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 12), (1, 2), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 12), (1, 2), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-720$ is divisible by $17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-720 % 17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{877,145,-793\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 877, 145, -793\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1095x \\equiv 1 \\pmod{1882}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(pow(1095, -1, 1882))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-888,-729\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -888, -729\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96377 \\pmod{97}$.", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "print(96377 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $586^m \\equiv 1 \\pmod{845}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(586, 845))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58830 \\pmod{41}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(58830 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20849)$.", + "Output Answer": [ + "$20848$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20849))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-60,223,900\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -60, 223, 900\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2495}{7119}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{208945669}-2495}{14238}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2495/7119)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{241,475\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 241, 475\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1373}{1960}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{17251529}-1373}{3920}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1373/1960)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-595,503,996\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -595, 503, 996\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5644$ is divisible by $17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5644 % 17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{861,-278,48\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 861, -278, 48\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27172)$.", + "Output Answer": [ + "$13584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27172))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1795)$.", + "Output Answer": [ + "$1432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1795))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $58699$.", + "Output Answer": [ + "$\\{2,3,7,10,11,15,23,32,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(58699):\n if len(roots) == 10: break\n if gcd(a, 58699) == 1 and is_primitive_root(a, 58699):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $894^388 \\pmod{2483}$.", + "Output Answer": [ + "$926$" + ], + "Output Program": [ + "print(pow(894, 388, 2483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{14}$\n$x \\equiv 16 \\pmod{3}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "constraints = (19, 14), (16, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 14), (16, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 14), (16, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12871)$.", + "Output Answer": [ + "$12600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12871))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1083}{1480}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9934489}-1083}{2960}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1083/1480)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n43953", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43953))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $928^524 \\pmod{1990}$.", + "Output Answer": [ + "$316$" + ], + "Output Program": [ + "print(pow(928, 524, 1990))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43068)$.", + "Output Answer": [ + "$13824$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43068))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $59982$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(59982 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $635x \\equiv 1 \\pmod{2398}$.", + "Output Answer": [ + "$1503$" + ], + "Output Program": [ + "print(pow(635, -1, 2398))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59548 \\pmod{93}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(59548 % 93)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31669 \\pmod{68}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(31669 % 68)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2039^1344 \\pmod{2966}$.", + "Output Answer": [ + "$1185$" + ], + "Output Program": [ + "print(pow(2039, 1344, 2966))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33354)$.", + "Output Answer": [ + "$10368$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33354))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14267}{14988}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1102107865}-14267}{29976}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14267/14988)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n67711", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(67711))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-303$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-303 % 22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1297}{1856}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{15461153}-1297}{3712}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1297/1856)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2460$ to base $36$.", + "Output Answer": [ + "$\\text{1wc}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2460\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-322,-224\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -322, -224\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2287^984 \\pmod{2524}$.", + "Output Answer": [ + "$713$" + ], + "Output Program": [ + "print(pow(2287, 984, 2524))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $57$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(57 % -3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $36654$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(36654 % -41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1283x \\equiv 1 \\pmod{1401}$.", + "Output Answer": [ + "$653$" + ], + "Output Program": [ + "print(pow(1283, -1, 1401))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $701^m \\equiv 1 \\pmod{902}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(701, 902))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 8 \\pmod{6}$\n$x \\equiv 2 \\pmod{7}$", + "Output Answer": [ + "$128$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 10), (11, 9), (8, 6), (2, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 10), (11, 9), (8, 6), (2, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $247x \\equiv 1 \\pmod{972}$.", + "Output Answer": [ + "$547$" + ], + "Output Program": [ + "print(pow(247, -1, 972))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 17 \\pmod{11}$", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 13), (17, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 13), (17, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (17, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 2 \\pmod{2}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (0, 16), (2, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 16), (2, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 18 \\pmod{7}$", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "constraints = (6, 15), (5, 4), (18, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 15), (5, 4), (18, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 15), (5, 4), (18, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1373x \\equiv 1 \\pmod{2181}$.", + "Output Answer": [ + "$359$" + ], + "Output Program": [ + "print(pow(1373, -1, 2181))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{649,-28,-473\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 649, -28, -473\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{889,-184\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 889, -184\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $694^820 \\pmod{2920}$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "print(pow(694, 820, 2920))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n102295", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2571}{698}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{29 \\sqrt{10177}-2571}{1396}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2571/698)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-62419$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-62419 % -37 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57970 \\pmod{59}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(57970 % 59)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-186,-187\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -186, -187\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $622^275 \\pmod{2568}$.", + "Output Answer": [ + "$2080$" + ], + "Output Program": [ + "print(pow(622, 275, 2568))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $47911$.", + "Output Answer": [ + "$\\{3,12,15,17,24,29,31,33,34,42\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(47911):\n if len(roots) == 10: break\n if gcd(a, 47911) == 1 and is_primitive_root(a, 47911):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{449,954,-692\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 449, 954, -692\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89644 \\pmod{54}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(89644 % 54)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n18515", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18515))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1750^2208 \\pmod{2247}$.", + "Output Answer": [ + "$1414$" + ], + "Output Program": [ + "print(pow(1750, 2208, 2247))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $174^1021 \\pmod{240}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "print(pow(174, 1021, 240))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36120)$.", + "Output Answer": [ + "$8064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36120))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 8), (13, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 8), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 8), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{1,-2,2,3\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = 1, -2, 2, 3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99036 \\pmod{86}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(99036 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35974)$.", + "Output Answer": [ + "$17986$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $155^1677 \\pmod{2886}$.", + "Output Answer": [ + "$935$" + ], + "Output Program": [ + "print(pow(155, 1677, 2886))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{17}$\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 10 \\pmod{3}$", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "constraints = (0, 17), (5, 4), (10, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (0, 17), (5, 4), (10, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 17), (5, 4), (10, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7}{6}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{12} \\left(\\sqrt{193}-7\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7/6)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1818^1525 \\pmod{2070}$.", + "Output Answer": [ + "$1818$" + ], + "Output Program": [ + "print(pow(1818, 1525, 2070))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2125^871 \\pmod{2345}$.", + "Output Answer": [ + "$1390$" + ], + "Output Program": [ + "print(pow(2125, 871, 2345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{608,-54\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 608, -54\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-188$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-188 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-299$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-299 % 8 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $283_{29}$ to base 10.", + "Output Answer": [ + "$1917$" + ], + "Output Program": [ + "n = '283'.strip('.')\nbase = 29\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-644,273,-902\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -644, 273, -902\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2400^1055 \\pmod{2488}$.", + "Output Answer": [ + "$400$" + ], + "Output Program": [ + "print(pow(2400, 1055, 2488))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-761,363\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -761, 363\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-231,-210,64\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -231, -210, 64\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{37,717,164\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 37, 717, 164\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{21801}{11809}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{41323741}-21801}{23618}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21801/11809)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{803,-951\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 803, -951\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8647}{1124}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{79824113}-8647}{2248}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8647/1124)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{137,476,-484\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 137, 476, -484\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $365x \\equiv 1 \\pmod{1118}$.", + "Output Answer": [ + "$729$" + ], + "Output Program": [ + "print(pow(365, -1, 1118))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2994$ to base $21$.", + "Output Answer": [ + "$\\text{6gc}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2994\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2021$ to base $2$.", + "Output Answer": [ + "$11111100101_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2021\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58796 \\pmod{38}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(58796 % 38)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{890}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 890))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2631$ to base $20$.", + "Output Answer": [ + "$\\text{6bb}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2631\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{29,123,-847\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 29, 123, -847\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1149^2382 \\pmod{2103}$.", + "Output Answer": [ + "$1617$" + ], + "Output Program": [ + "print(pow(1149, 2382, 2103))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $61167$.", + "Output Answer": [ + "$3^1\\cdot 20389^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(61167))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{15}$\n$x \\equiv 5 \\pmod{3}$\n$x \\equiv 10 \\pmod{4}$", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 15), (5, 3), (10, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 15), (5, 3), (10, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{3}$\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 5 \\pmod{7}$", + "Output Answer": [ + "$3246$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 3), (9, 13), (16, 17), (5, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 3), (9, 13), (16, 17), (5, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 3), (9, 13), (16, 17), (5, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28026)$.", + "Output Answer": [ + "$9288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28026))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1559x \\equiv 1 \\pmod{1803}$.", + "Output Answer": [ + "$968$" + ], + "Output Program": [ + "print(pow(1559, -1, 1803))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{20}$\n$x \\equiv 15 \\pmod{16}$\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 11 \\pmod{18}$", + "Output Answer": [ + "$911$" + ], + "Output Program": [ + "constraints = (11, 20), (15, 16), (20, 11), (11, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 20), (15, 16), (20, 11), (11, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30866)$.", + "Output Answer": [ + "$13200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30866))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39272)$.", + "Output Answer": [ + "$19632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39272))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1534 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(1534 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n66467", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66467))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10299}{752}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{108331417}-10299}{1504}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10299/752)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15282)$.", + "Output Answer": [ + "$5076$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15282))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{8}$\n$x \\equiv 4 \\pmod{7}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "constraints = (4, 8), (4, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 8), (4, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 8), (4, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $464^2245 \\pmod{2704}$.", + "Output Answer": [ + "$1296$" + ], + "Output Program": [ + "print(pow(464, 2245, 2704))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{83,-429,63\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 83, -429, 63\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $56^m \\equiv 1 \\pmod{213}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(56, 213))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $757$ to base $30$.", + "Output Answer": [ + "$\\text{p7}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 757\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $251^m \\equiv 1 \\pmod{462}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(251, 462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $271^m \\equiv 1 \\pmod{483}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(271, 483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $584x \\equiv 1 \\pmod{1957}$.", + "Output Answer": [ + "$1136$" + ], + "Output Program": [ + "print(pow(584, -1, 1957))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $181x \\equiv 1 \\pmod{628}$.", + "Output Answer": [ + "$229$" + ], + "Output Program": [ + "print(pow(181, -1, 628))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1182$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1182 % 9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $9959$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9959 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2110^1777 \\pmod{2342}$.", + "Output Answer": [ + "$1842$" + ], + "Output Program": [ + "print(pow(2110, 1777, 2342))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $112^1884 \\pmod{2630}$.", + "Output Answer": [ + "$976$" + ], + "Output Program": [ + "print(pow(112, 1884, 2630))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48021)$.", + "Output Answer": [ + "$32012$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48021))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15173)$.", + "Output Answer": [ + "$15172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15173))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $483^m \\equiv 1 \\pmod{550}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(483, 550))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{529}{1140}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5478241}-529}{2280}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(529/1140)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{112,-18,-55\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 112, -18, -55\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $7400$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7400 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22357}{40066}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6920972873}-22357}{80132}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22357/40066)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-750,517,-727\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -750, 517, -727\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{9}$\n$x \\equiv 5 \\pmod{8}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 9), (5, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 9), (5, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 9), (5, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $46674$.", + "Output Answer": [ + "$2^1\\cdot 3^2\\cdot 2593^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(46674))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $78107$.", + "Output Answer": [ + "$37^1\\cdot 2111^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(78107))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{13}$\n$x \\equiv 6 \\pmod{14}$", + "Output Answer": [ + "$146$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 13), (6, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 13), (6, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 13), (6, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8746 \\pmod{76}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(8746 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-75456$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-75456 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{25675}{20226}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2295569929}-25675}{40452}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25675/20226)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1306^1772 \\pmod{2556}$.", + "Output Answer": [ + "$712$" + ], + "Output Program": [ + "print(pow(1306, 1772, 2556))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4248}{2809}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{42913}-2124}{2809}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4248/2809)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6411}{2621}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{68579485}-6411}{5242}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6411/2621)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{18}$\n$x \\equiv 4 \\pmod{5}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 18), (4, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 18), (4, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 18), (4, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $31847$.", + "Output Answer": [ + "$\\{5,7,10,14,15,17,20,21,28,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(31847):\n if len(roots) == 10: break\n if gcd(a, 31847) == 1 and is_primitive_root(a, 31847):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-967,334\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -967, 334\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35961)$.", + "Output Answer": [ + "$23972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35961))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1337x \\equiv 1 \\pmod{1381}$.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "print(pow(1337, -1, 1381))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30715 \\pmod{67}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(30715 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2945$ to base $22$.", + "Output Answer": [ + "$\\text{61j}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2945\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{18}$\n$x \\equiv 13 \\pmod{15}$\n$x \\equiv 19 \\pmod{17}$", + "Output Answer": [ + "$733$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 18), (13, 15), (19, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 18), (13, 15), (19, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4770$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4770 % 15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{5}$\n$x \\equiv 20 \\pmod{3}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 5), (20, 3), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 5), (20, 3), (14, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 5), (20, 3), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1869^610 \\pmod{2832}$.", + "Output Answer": [ + "$2025$" + ], + "Output Program": [ + "print(pow(1869, 610, 2832))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n67633", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(67633))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1269x \\equiv 1 \\pmod{2042}$.", + "Output Answer": [ + "$1725$" + ], + "Output Program": [ + "print(pow(1269, -1, 2042))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{7}$\n$x \\equiv 20 \\pmod{13}$", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "constraints = (8, 7), (20, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 7), (20, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 7), (20, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n17399", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(17399))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{29224}{32881}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1294670705}-14612}{32881}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29224/32881)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10171}{7198}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{310694057}-10171}{14396}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10171/7198)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 28050 \\pmod{95}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(28050 % 95)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n103089", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(103089))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-17238$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-17238 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $380$ to base $7$.", + "Output Answer": [ + "$1052_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 380\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-747,-136\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -747, -136\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34263)$.", + "Output Answer": [ + "$22356$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34263))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $53859$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(53859 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{12}$\n$x \\equiv 2 \\pmod{13}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 12), (2, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 12), (2, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 12), (2, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1693}{5819}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{138309293}-1693}{11638}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1693/5819)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3198}{563}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{563} \\left(\\sqrt{2873770}-1599\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3198/563)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{579,808,-91\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 579, 808, -91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $932^2261 \\pmod{1883}$.", + "Output Answer": [ + "$1100$" + ], + "Output Program": [ + "print(pow(932, 2261, 1883))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $211x \\equiv 1 \\pmod{2048}$.", + "Output Answer": [ + "$1883$" + ], + "Output Program": [ + "print(pow(211, -1, 2048))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{2}$\n$x \\equiv 3 \\pmod{14}$\n$x \\equiv 1 \\pmod{15}$\n$x \\equiv 9 \\pmod{19}$", + "Output Answer": [ + "$3391$" + ], + "Output Program": [ + "constraints = (17, 2), (3, 14), (1, 15), (9, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 2), (3, 14), (1, 15), (9, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9367}{734}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{89895713}-9367}{1468}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9367/734)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $211^122 \\pmod{2846}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(211, 122, 2846))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2004^1550 \\pmod{2890}$.", + "Output Answer": [ + "$1356$" + ], + "Output Program": [ + "print(pow(2004, 1550, 2890))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $344x \\equiv 1 \\pmod{719}$.", + "Output Answer": [ + "$487$" + ], + "Output Program": [ + "print(pow(344, -1, 719))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11261 \\pmod{52}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(11261 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32076 \\pmod{7}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(32076 % 7)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1348x \\equiv 1 \\pmod{1571}$.", + "Output Answer": [ + "$472$" + ], + "Output Program": [ + "print(pow(1348, -1, 1571))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $132$ is divisible by $3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(132 % 3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30210 \\pmod{19}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(30210 % 19)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $45x \\equiv 1 \\pmod{668}$.", + "Output Answer": [ + "$193$" + ], + "Output Program": [ + "print(pow(45, -1, 668))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{6}$\n$x \\equiv 15 \\pmod{13}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 6), (15, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 6), (15, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 6), (15, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $34333$.", + "Output Answer": [ + "$13^1\\cdot 19^1\\cdot 139^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(34333))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2072^1240 \\pmod{2295}$.", + "Output Answer": [ + "$2041$" + ], + "Output Program": [ + "print(pow(2072, 1240, 2295))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40647 \\pmod{48}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(40647 % 48)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $345x \\equiv 1 \\pmod{521}$.", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "print(pow(345, -1, 521))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1582^2264 \\pmod{2143}$.", + "Output Answer": [ + "$713$" + ], + "Output Program": [ + "print(pow(1582, 2264, 2143))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2210^140 \\pmod{2764}$.", + "Output Answer": [ + "$1676$" + ], + "Output Program": [ + "print(pow(2210, 140, 2764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2377^1225 \\pmod{2694}$.", + "Output Answer": [ + "$2623$" + ], + "Output Program": [ + "print(pow(2377, 1225, 2694))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $18469$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18469 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $28142$.", + "Output Answer": [ + "$\\{7,15,23,31,59,65,67,79,83,85\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(28142):\n if len(roots) == 10: break\n if gcd(a, 28142) == 1 and is_primitive_root(a, 28142):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2044}{3001}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10050485}-1022}{3001}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2044/3001)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 2), (3, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 2), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 2), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $63x \\equiv 1 \\pmod{127}$.", + "Output Answer": [ + "$125$" + ], + "Output Program": [ + "print(pow(63, -1, 127))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $11893$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(11893 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n34257", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(34257))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{8}$\n$x \\equiv 5 \\pmod{19}$\n$x \\equiv 14 \\pmod{17}$", + "Output Answer": [ + "$2513$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 8), (5, 19), (14, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 8), (5, 19), (14, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 8), (5, 19), (14, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $15^1740 \\pmod{305}$.", + "Output Answer": [ + "$245$" + ], + "Output Program": [ + "print(pow(15, 1740, 305))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-591,-469\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -591, -469\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86408 \\pmod{39}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(86408 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32931)$.", + "Output Answer": [ + "$21948$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32931))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21129)$.", + "Output Answer": [ + "$14084$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21129))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1090^2295 \\pmod{2996}$.", + "Output Answer": [ + "$692$" + ], + "Output Program": [ + "print(pow(1090, 2295, 2996))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41603$.", + "Output Answer": [ + "$\\{2,5,6,7,8,11,15,18,20,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41603):\n if len(roots) == 10: break\n if gcd(a, 41603) == 1 and is_primitive_root(a, 41603):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $330$ is divisible by $3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(330 % 3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1718^1952 \\pmod{2498}$.", + "Output Answer": [ + "$1342$" + ], + "Output Program": [ + "print(pow(1718, 1952, 2498))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-90$ is divisible by $7$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-90 % 7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9583 \\pmod{37}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(9583 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1332^1958 \\pmod{2450}$.", + "Output Answer": [ + "$1474$" + ], + "Output Program": [ + "print(pow(1332, 1958, 2450))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3989}{7358}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{232472777}-3989}{14716}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3989/7358)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $877^1588 \\pmod{2702}$.", + "Output Answer": [ + "$1787$" + ], + "Output Program": [ + "print(pow(877, 1588, 2702))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32262 \\pmod{7}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(32262 % 7)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $13878$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(13878 % 18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{8}$\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 11 \\pmod{9}$", + "Output Answer": [ + "$3521$" + ], + "Output Program": [ + "constraints = (9, 8), (12, 11), (11, 10), (11, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 8), (12, 11), (11, 10), (11, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-32671$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-32671 % -37 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $478^648 \\pmod{839}$.", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "print(pow(478, 648, 839))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{496,519,-530\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 496, 519, -530\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.13$ to base $33$.", + "Output Answer": [ + "$\\text{0.49ir}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.13\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{368,899,-824\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 368, 899, -824\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7600}{3483}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{26571289}-3800}{3483}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7600/3483)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8813)$.", + "Output Answer": [ + "$7548$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8813))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n54765", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54765))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1529x \\equiv 1 \\pmod{1704}$.", + "Output Answer": [ + "$185$" + ], + "Output Program": [ + "print(pow(1529, -1, 1704))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-75306$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-75306 % 42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43043)$.", + "Output Answer": [ + "$30240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43043))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34060)$.", + "Output Answer": [ + "$12480$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41254$.", + "Output Answer": [ + "$\\{5,15,17,29,35,37,45,51,55,59\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41254):\n if len(roots) == 10: break\n if gcd(a, 41254) == 1 and is_primitive_root(a, 41254):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $8998$ is divisible by $22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8998 % 22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1235$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1235 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n4953", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4953))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4274)$.", + "Output Answer": [ + "$2136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4274))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $717$ to base $13$.", + "Output Answer": [ + "$432_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 717\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n72221", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(72221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1821^539 \\pmod{2597}$.", + "Output Answer": [ + "$687$" + ], + "Output Program": [ + "print(pow(1821, 539, 2597))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86024 \\pmod{29}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(86024 % 29)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{886,819,237\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 886, 819, 237\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $33600$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(33600 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2379^1143 \\pmod{2656}$.", + "Output Answer": [ + "$1251$" + ], + "Output Program": [ + "print(pow(2379, 1143, 2656))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-731$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-731 % -19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $164^m \\equiv 1 \\pmod{171}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(164, 171))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29457 \\pmod{78}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(29457 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58504 \\pmod{75}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(58504 % 75)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15460 \\pmod{69}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(15460 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 11 \\pmod{20}$\n$x \\equiv 13 \\pmod{14}$\n$x \\equiv 16 \\pmod{3}$", + "Output Answer": [ + "$5851$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (11, 20), (13, 14), (16, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 19), (11, 20), (13, 14), (16, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 7 \\pmod{13}$\n$x \\equiv 0 \\pmod{2}$", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "import math\n\nconstraints = (12, 7), (7, 13), (0, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (7, 13), (0, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 7), (7, 13), (0, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 9 \\pmod{13}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 17), (9, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 17), (9, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 17), (9, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 9 \\pmod{14}$", + "Output Answer": [ + "$261$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 15), (14, 13), (9, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 15), (14, 13), (9, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 15), (14, 13), (9, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21454)$.", + "Output Answer": [ + "$10080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21454))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17448)$.", + "Output Answer": [ + "$5808$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17448))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $66^435 \\pmod{1400}$.", + "Output Answer": [ + "$776$" + ], + "Output Program": [ + "print(pow(66, 435, 1400))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $810x \\equiv 1 \\pmod{2483}$.", + "Output Answer": [ + "$2155$" + ], + "Output Program": [ + "print(pow(810, -1, 2483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4453}{319}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{638} \\left(\\sqrt{20236253}-4453\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4453/319)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $555^1577 \\pmod{2616}$.", + "Output Answer": [ + "$1563$" + ], + "Output Program": [ + "print(pow(555, 1577, 2616))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.592$ to base $13$.", + "Output Answer": [ + "$0.79081_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.592\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $611^175 \\pmod{2680}$.", + "Output Answer": [ + "$1851$" + ], + "Output Program": [ + "print(pow(611, 175, 2680))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27901}{38457}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6694229197}-27901}{76914}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27901/38457)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12219 \\pmod{48}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(12219 % 48)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2089^30 \\pmod{2314}$.", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "print(pow(2089, 30, 2314))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2345^1305 \\pmod{2383}$.", + "Output Answer": [ + "$1188$" + ], + "Output Program": [ + "print(pow(2345, 1305, 2383))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6997}{772}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{51341945}-6997}{1544}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6997/772)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $166^1074 \\pmod{1056}$.", + "Output Answer": [ + "$1024$" + ], + "Output Program": [ + "print(pow(166, 1074, 1056))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62754 \\pmod{40}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(62754 % 40)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n18841", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18841))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $878x \\equiv 1 \\pmod{2229}$.", + "Output Answer": [ + "$1475$" + ], + "Output Program": [ + "print(pow(878, -1, 2229))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2269^1206 \\pmod{2324}$.", + "Output Answer": [ + "$645$" + ], + "Output Program": [ + "print(pow(2269, 1206, 2324))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2269$ to base $4$.", + "Output Answer": [ + "$203131_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2269\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $101x \\equiv 1 \\pmod{196}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(pow(101, -1, 196))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2287^443 \\pmod{2737}$.", + "Output Answer": [ + "$1851$" + ], + "Output Program": [ + "print(pow(2287, 443, 2737))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29976 \\pmod{86}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(29976 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7049)$.", + "Output Answer": [ + "$5616$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7049))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-676$ is divisible by $4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-676 % 4 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (10, 2), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 2), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $17220$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(17220 % 42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9577}{10949}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{571241333}-9577}{21898}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9577/10949)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13931}{5445}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{312664861}-13931}{10890}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13931/5445)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{639,-89\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 639, -89\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20386 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(20386 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{18}$\n$x \\equiv 12 \\pmod{4}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 18), (12, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 18), (12, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{73,823,160\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 73, 823, 160\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $317^m \\equiv 1 \\pmod{979}$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(317, 979))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2092x \\equiv 1 \\pmod{2291}$.", + "Output Answer": [ + "$921$" + ], + "Output Program": [ + "print(pow(2092, -1, 2291))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $61^2196 \\pmod{1913}$.", + "Output Answer": [ + "$1450$" + ], + "Output Program": [ + "print(pow(61, 2196, 1913))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 7 \\pmod{18}$\n$x \\equiv 7 \\pmod{16}$\n$x \\equiv 5 \\pmod{14}$", + "Output Answer": [ + "$439$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (7, 18), (7, 16), (5, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 7), (7, 18), (7, 16), (5, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $3^m \\equiv 1 \\pmod{142}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(3, 142))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9359}{15665}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1069159781}-9359}{31330}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9359/15665)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $592^1201 \\pmod{2566}$.", + "Output Answer": [ + "$2534$" + ], + "Output Program": [ + "print(pow(592, 1201, 2566))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1326^297 \\pmod{2024}$.", + "Output Answer": [ + "$712$" + ], + "Output Program": [ + "print(pow(1326, 297, 2024))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n21025", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21025))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2315$ to base $30$.", + "Output Answer": [ + "$\\text{2h5}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2315\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $57394$.", + "Output Answer": [ + "$\\{3,5,13,21,27,31,33,35,37,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(57394):\n if len(roots) == 10: break\n if gcd(a, 57394) == 1 and is_primitive_root(a, 57394):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$104$" + ], + "Output Program": [ + "constraints = (6, 14), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 14), (13, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 14), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-277$ is divisible by $-6$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-277 % -6 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $433^m \\equiv 1 \\pmod{946}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(433, 946))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $80571$.", + "Output Answer": [ + "$3^1\\cdot 107^1\\cdot 251^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(80571))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.797$ to base $26$.", + "Output Answer": [ + "$\\text{0.kik2}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.797\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-209,-234\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -209, -234\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $782^m \\equiv 1 \\pmod{927}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(782, 927))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43646)$.", + "Output Answer": [ + "$21528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43646))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91417 \\pmod{71}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(91417 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $510^2279 \\pmod{1393}$.", + "Output Answer": [ + "$405$" + ], + "Output Program": [ + "print(pow(510, 2279, 1393))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $308^430 \\pmod{1936}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(308, 430, 1936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1071^57 \\pmod{1566}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(pow(1071, 57, 1566))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2244$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2244 % 12 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $997x \\equiv 1 \\pmod{2164}$.", + "Output Answer": [ + "$1693$" + ], + "Output Program": [ + "print(pow(997, -1, 2164))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 18901 \\pmod{31}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(18901 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2435^2023 \\pmod{2907}$.", + "Output Answer": [ + "$914$" + ], + "Output Program": [ + "print(pow(2435, 2023, 2907))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1874^2149 \\pmod{1925}$.", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "print(pow(1874, 2149, 1925))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1217x \\equiv 1 \\pmod{2154}$.", + "Output Answer": [ + "$977$" + ], + "Output Program": [ + "print(pow(1217, -1, 2154))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48359)$.", + "Output Answer": [ + "$47016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48359))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72608 \\pmod{15}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(72608 % 15)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40802)$.", + "Output Answer": [ + "$19492$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40802))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{2}$\n$x \\equiv 5 \\pmod{5}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (20, 2), (5, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 2), (5, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 2), (5, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37066)$.", + "Output Answer": [ + "$18060$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37066))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $1^m \\equiv 1 \\pmod{64}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(1, 64))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $129^m \\equiv 1 \\pmod{365}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(129, 365))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-907,774,780\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -907, 774, 780\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75741 \\pmod{87}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(75741 % 87)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $257$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(257 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5254 \\pmod{86}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(5254 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n64221", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $451^m \\equiv 1 \\pmod{876}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(451, 876))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{23153}{26575}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3360983909}-23153}{53150}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23153/26575)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n96183", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(96183))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "constraints = (0, 20), (16, 4), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 20), (16, 4), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $43741$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(43741 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-273,51\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -273, 51\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $325x \\equiv 1 \\pmod{1054}$.", + "Output Answer": [ + "$587$" + ], + "Output Program": [ + "print(pow(325, -1, 1054))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{679,-701\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 679, -701\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43508)$.", + "Output Answer": [ + "$21312$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43508))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-3531$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3531 % -33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $105^m \\equiv 1 \\pmod{502}$.", + "Output Answer": [ + "$125$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(105, 502))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.073$ to base $24$.", + "Output Answer": [ + "$\\text{0.1i14}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.073\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47601 \\pmod{96}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(47601 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1335$ to base $35$.", + "Output Answer": [ + "$135_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1335\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $187x \\equiv 1 \\pmod{1050}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(187, -1, 1050))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $637x \\equiv 1 \\pmod{1627}$.", + "Output Answer": [ + "$613$" + ], + "Output Program": [ + "print(pow(637, -1, 1627))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $392x \\equiv 1 \\pmod{2217}$.", + "Output Answer": [ + "$854$" + ], + "Output Program": [ + "print(pow(392, -1, 2217))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.851$ to base $20$.", + "Output Answer": [ + "$\\text{0.h08}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.851\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $35974$.", + "Output Answer": [ + "$\\{5,7,13,15,21,23,37,39,41,43\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(35974):\n if len(roots) == 10: break\n if gcd(a, 35974) == 1 and is_primitive_root(a, 35974):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{10}$\n$x \\equiv 11 \\pmod{19}$\n$x \\equiv 2 \\pmod{6}$\n$x \\equiv 11 \\pmod{7}$", + "Output Answer": [ + "$3602$" + ], + "Output Program": [ + "constraints = (12, 10), (11, 19), (2, 6), (11, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 10), (11, 19), (2, 6), (11, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{249,-505,765\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 249, -505, 765\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-707,-699\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -707, -699\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3180)$.", + "Output Answer": [ + "$832$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3180))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-855,-674,41\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -855, -674, 41\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-281,-348\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -281, -348\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97004 \\pmod{77}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(97004 % 77)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45175)$.", + "Output Answer": [ + "$33120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $907x \\equiv 1 \\pmod{1914}$.", + "Output Answer": [ + "$823$" + ], + "Output Program": [ + "print(pow(907, -1, 1914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n2621", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2621))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{571,80\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 571, 80\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $598$ to base $33$.", + "Output Answer": [ + "$\\text{i4}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 598\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27205 \\pmod{51}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(27205 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30692 \\pmod{19}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(30692 % 19)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4823}{7666}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{258331553}-4823}{15332}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4823/7666)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $762^804 \\pmod{2122}$.", + "Output Answer": [ + "$946$" + ], + "Output Program": [ + "print(pow(762, 804, 2122))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4724}{2789}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{13357565}-2362}{2789}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4724/2789)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35753)$.", + "Output Answer": [ + "$35752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11517)$.", + "Output Answer": [ + "$6960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11517))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1.$ to base $23$.", + "Output Answer": [ + "$1._{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1.\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{287,-860\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 287, -860\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1596^2414 \\pmod{2176}$.", + "Output Answer": [ + "$1152$" + ], + "Output Program": [ + "print(pow(1596, 2414, 2176))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $120220_3$ to base 10.", + "Output Answer": [ + "$429$" + ], + "Output Program": [ + "n = '120220'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n41039", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(41039))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1156x \\equiv 1 \\pmod{1399}$.", + "Output Answer": [ + "$403$" + ], + "Output Program": [ + "print(pow(1156, -1, 1399))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $246_{31}$ to base 10.", + "Output Answer": [ + "$2052$" + ], + "Output Program": [ + "n = '246'.strip('.')\nbase = 31\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{299,-480,675\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 299, -480, 675\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n45493", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(45493))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-771$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-771 % 9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41199)$.", + "Output Answer": [ + "$26520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41199))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-32130$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-32130 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $573^1961 \\pmod{738}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(pow(573, 1961, 738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1115^1009 \\pmod{1335}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(pow(1115, 1009, 1335))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-683$ is divisible by $43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-683 % 43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84611 \\pmod{34}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(84611 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-789,650,4\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -789, 650, 4\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $155^m \\equiv 1 \\pmod{524}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(155, 524))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $37313$.", + "Output Answer": [ + "$\\{3,5,6,7,10,12,14,20,23,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(37313):\n if len(roots) == 10: break\n if gcd(a, 37313) == 1 and is_primitive_root(a, 37313):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $47430$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(47430 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{11}$\n$x \\equiv 9 \\pmod{10}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "constraints = (19, 11), (9, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 11), (9, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 11), (9, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $69^m \\equiv 1 \\pmod{266}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(69, 266))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{609,467\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 609, 467\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1734$ to base $35$.", + "Output Answer": [ + "$\\text{1ej}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1734\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $211^m \\equiv 1 \\pmod{924}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(211, 924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 14 \\pmod{13}$", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "import math\n\nconstraints = (11, 17), (7, 2), (14, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 17), (7, 2), (14, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 17), (7, 2), (14, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $121x \\equiv 1 \\pmod{2066}$.", + "Output Answer": [ + "$1605$" + ], + "Output Program": [ + "print(pow(121, -1, 2066))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98000 \\pmod{9}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(98000 % 9)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{7}$\n$x \\equiv 1 \\pmod{9}$\n$x \\equiv 19 \\pmod{6}$", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 7), (1, 9), (19, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 7), (1, 9), (19, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1405}{5173}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{109013741}-1405}{10346}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1405/5173)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1929^490 \\pmod{2398}$.", + "Output Answer": [ + "$2179$" + ], + "Output Program": [ + "print(pow(1929, 490, 2398))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22510)$.", + "Output Answer": [ + "$9000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22510))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $435^m \\equiv 1 \\pmod{548}$.", + "Output Answer": [ + "$136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(435, 548))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9099}{9362}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{433379977}-9099}{18724}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9099/9362)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6169}{12796}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{27720281}-6169}{25592}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6169/12796)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{907,-622,231\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 907, -622, 231\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7345)$.", + "Output Answer": [ + "$5376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n32647", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(32647))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $57329$.", + "Output Answer": [ + "$\\{3,6,7,11,12,14,15,17,22,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(57329):\n if len(roots) == 10: break\n if gcd(a, 57329) == 1 and is_primitive_root(a, 57329):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42961)$.", + "Output Answer": [ + "$42960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42961))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2350^1006 \\pmod{2606}$.", + "Output Answer": [ + "$1488$" + ], + "Output Program": [ + "print(pow(2350, 1006, 2606))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{435,469,-337\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 435, 469, -337\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $651x \\equiv 1 \\pmod{1402}$.", + "Output Answer": [ + "$715$" + ], + "Output Program": [ + "print(pow(651, -1, 1402))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4988}{5199}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{33249637}-2494}{5199}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4988/5199)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5666}{7579}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{65467130}-2833}{7579}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5666/7579)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-15$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-15 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2385^1852 \\pmod{2830}$.", + "Output Answer": [ + "$375$" + ], + "Output Program": [ + "print(pow(2385, 1852, 2830))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $20506$.", + "Output Answer": [ + "$\\{3,5,7,19,27,31,33,39,41,43\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(20506):\n if len(roots) == 10: break\n if gcd(a, 20506) == 1 and is_primitive_root(a, 20506):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3640)$.", + "Output Answer": [ + "$1152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3640))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1711$ to base $20$.", + "Output Answer": [ + "$\\text{45b}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1711\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2398^2004 \\pmod{2557}$.", + "Output Answer": [ + "$1508$" + ], + "Output Program": [ + "print(pow(2398, 2004, 2557))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $54646$.", + "Output Answer": [ + "$2^1\\cdot 89^1\\cdot 307^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(54646))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3703}{12130}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{602259809}-3703}{24260}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3703/12130)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n104625", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(104625))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{931}{83}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{166} \\left(\\sqrt{894317}-931\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(931/83)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1059$ to base $22$.", + "Output Answer": [ + "$243_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1059\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $8704$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8704 % -32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-414,693\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -414, 693\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7647}{2278}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{79233745}-7647}{4556}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7647/2278)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41550)$.", + "Output Answer": [ + "$11040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41550))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $179^m \\equiv 1 \\pmod{545}$.", + "Output Answer": [ + "$108$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(179, 545))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.249$ to base $25$.", + "Output Answer": [ + "$\\text{0.65fg}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.249\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $601^129 \\pmod{2336}$.", + "Output Answer": [ + "$793$" + ], + "Output Program": [ + "print(pow(601, 129, 2336))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1919^1222 \\pmod{2153}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(1919, 1222, 2153))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{831,422,-199\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 831, 422, -199\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $829^1148 \\pmod{854}$.", + "Output Answer": [ + "$849$" + ], + "Output Program": [ + "print(pow(829, 1148, 854))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16417)$.", + "Output Answer": [ + "$16416$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16417))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-81,231,56\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -81, 231, 56\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19313)$.", + "Output Answer": [ + "$15840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19313))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1553x \\equiv 1 \\pmod{2282}$.", + "Output Answer": [ + "$1105$" + ], + "Output Program": [ + "print(pow(1553, -1, 2282))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4710$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4710 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{6}$\n$x \\equiv 1 \\pmod{17}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "import math\n\nconstraints = (15, 6), (1, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 6), (1, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 6), (1, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.4125413_7$ to base 10.", + "Output Answer": [ + "$0.6$" + ], + "Output Program": [ + "n = '0.4125413'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{36814}{29173}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1189881578}-18407}{29173}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36814/29173)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.538$ to base $19$.", + "Output Answer": [ + "$\\text{0.a442d}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.538\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1939^1065 \\pmod{2560}$.", + "Output Answer": [ + "$1139$" + ], + "Output Program": [ + "print(pow(1939, 1065, 2560))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-512,229,-606\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -512, 229, -606\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1189^1037 \\pmod{2675}$.", + "Output Answer": [ + "$1004$" + ], + "Output Program": [ + "print(pow(1189, 1037, 2675))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1334^2086 \\pmod{2894}$.", + "Output Answer": [ + "$1638$" + ], + "Output Program": [ + "print(pow(1334, 2086, 2894))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 5 \\pmod{17}$\n$x \\equiv 0 \\pmod{14}$\n$x \\equiv 8 \\pmod{12}$", + "Output Answer": [ + "$1484$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 5), (5, 17), (0, 14), (8, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 5), (5, 17), (0, 14), (8, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{58,33\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 58, 33\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3399 \\pmod{89}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(3399 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{979}{1104}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5833705}-979}{2208}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(979/1104)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $14688$.", + "Output Answer": [ + "$2^5\\cdot 3^3\\cdot 17^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(14688))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2192^1191 \\pmod{2401}$.", + "Output Answer": [ + "$967$" + ], + "Output Program": [ + "print(pow(2192, 1191, 2401))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $884^1925 \\pmod{2363}$.", + "Output Answer": [ + "$646$" + ], + "Output Program": [ + "print(pow(884, 1925, 2363))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $821x \\equiv 1 \\pmod{1708}$.", + "Output Answer": [ + "$1061$" + ], + "Output Program": [ + "print(pow(821, -1, 1708))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48249)$.", + "Output Answer": [ + "$32148$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48249))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{4}$\n$x \\equiv 7 \\pmod{9}$\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 2 \\pmod{17}$", + "Output Answer": [ + "$4201$" + ], + "Output Program": [ + "constraints = (17, 4), (7, 9), (1, 7), (2, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 4), (7, 9), (1, 7), (2, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 4), (7, 9), (1, 7), (2, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{18}$\n$x \\equiv 10 \\pmod{11}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 18), (10, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 18), (10, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 18), (10, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1109^1678 \\pmod{2683}$.", + "Output Answer": [ + "$264$" + ], + "Output Program": [ + "print(pow(1109, 1678, 2683))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{6}$\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 9 \\pmod{10}$", + "Output Answer": [ + "$249$" + ], + "Output Program": [ + "constraints = (9, 6), (18, 11), (9, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 6), (18, 11), (9, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $511^m \\equiv 1 \\pmod{858}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(511, 858))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43859 \\pmod{37}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(43859 % 37)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n90679", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(90679))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17671)$.", + "Output Answer": [ + "$17200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17671))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71069 \\pmod{51}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(71069 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $81^m \\equiv 1 \\pmod{140}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(81, 140))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $949^m \\equiv 1 \\pmod{966}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(949, 966))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1973^1476 \\pmod{2851}$.", + "Output Answer": [ + "$1969$" + ], + "Output Program": [ + "print(pow(1973, 1476, 2851))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1009x \\equiv 1 \\pmod{1889}$.", + "Output Answer": [ + "$1479$" + ], + "Output Program": [ + "print(pow(1009, -1, 1889))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n5741", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5741))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8235}{7289}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{280333309}-8235}{14578}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8235/7289)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{333,819,571\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 333, 819, 571\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57040 \\pmod{49}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(57040 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $357^m \\equiv 1 \\pmod{565}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(357, 565))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $200$ is divisible by $13$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(200 % 13 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{939,260,823\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 939, 260, 823\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $201^m \\equiv 1 \\pmod{340}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(201, 340))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-286,604,159\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -286, 604, 159\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n83441", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83441))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1425x \\equiv 1 \\pmod{1492}$.", + "Output Answer": [ + "$913$" + ], + "Output Program": [ + "print(pow(1425, -1, 1492))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-946$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-946 % 28 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1091)$.", + "Output Answer": [ + "$1090$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1091))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2943$ to base $5$.", + "Output Answer": [ + "$43233_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2943\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{5}$\n$x \\equiv 12 \\pmod{14}$\n$x \\equiv 4 \\pmod{4}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$1328$" + ], + "Output Program": [ + "constraints = (8, 5), (12, 14), (4, 4), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 5), (12, 14), (4, 4), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84028 \\pmod{66}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(84028 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-772$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-772 % -33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $3720$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3720 % -10 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{41097}{41632}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8621857105}-41097}{83264}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(41097/41632)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 6 \\pmod{11}$", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "constraints = (18, 5), (6, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 5), (6, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 5), (6, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{602,-179\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 602, -179\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47010)$.", + "Output Answer": [ + "$12528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47010))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-410,79,-169\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -410, 79, -169\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2317$ to base $20$.", + "Output Answer": [ + "$\\text{5fh}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2317\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $47x \\equiv 1 \\pmod{1163}$.", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "print(pow(47, -1, 1163))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21565)$.", + "Output Answer": [ + "$16272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21565))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1004$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1004 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $49^221 \\pmod{342}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(49, 221, 342))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $485x \\equiv 1 \\pmod{1596}$.", + "Output Answer": [ + "$1313$" + ], + "Output Program": [ + "print(pow(485, -1, 1596))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20283)$.", + "Output Answer": [ + "$13520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20283))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $575^m \\equiv 1 \\pmod{642}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(575, 642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n42207", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(42207))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1819}{873}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6357277}-1819}{1746}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1819/873)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n86937", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(86937))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $99533$.", + "Output Answer": [ + "$7^1\\cdot 59^1\\cdot 241^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(99533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $579x \\equiv 1 \\pmod{2015}$.", + "Output Answer": [ + "$964$" + ], + "Output Program": [ + "print(pow(579, -1, 2015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{6}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 6), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 6), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 6), (16, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62166 \\pmod{51}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(62166 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $387_{15}$ to base 10.", + "Output Answer": [ + "$802$" + ], + "Output Program": [ + "n = '387'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36758)$.", + "Output Answer": [ + "$18378$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36758))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $489^m \\equiv 1 \\pmod{694}$.", + "Output Answer": [ + "$346$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(489, 694))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1440^1460 \\pmod{2206}$.", + "Output Answer": [ + "$666$" + ], + "Output Program": [ + "print(pow(1440, 1460, 2206))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86974 \\pmod{83}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(86974 % 83)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $505^1971 \\pmod{2116}$.", + "Output Answer": [ + "$689$" + ], + "Output Program": [ + "print(pow(505, 1971, 2116))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1896}{683}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{683} \\left(\\sqrt{1365193}-948\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1896/683)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $262^1615 \\pmod{530}$.", + "Output Answer": [ + "$238$" + ], + "Output Program": [ + "print(pow(262, 1615, 530))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1183x \\equiv 1 \\pmod{1214}$.", + "Output Answer": [ + "$979$" + ], + "Output Program": [ + "print(pow(1183, -1, 1214))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1321x \\equiv 1 \\pmod{2426}$.", + "Output Answer": [ + "$1067$" + ], + "Output Program": [ + "print(pow(1321, -1, 2426))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28523)$.", + "Output Answer": [ + "$25920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28523))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $420$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(420 % 9 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-897,202\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -897, 202\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3530 \\pmod{95}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(3530 % 95)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n69541", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(69541))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71867 \\pmod{27}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(71867 % 27)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 17 \\pmod{18}$", + "Output Answer": [ + "$107$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (17, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (17, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 11), (17, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1638x \\equiv 1 \\pmod{2237}$.", + "Output Answer": [ + "$1632$" + ], + "Output Program": [ + "print(pow(1638, -1, 2237))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{823}{504}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1693393}-823}{1008}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(823/504)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13145}{10082}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{579377921}-13145}{20164}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13145/10082)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{14}$\n$x \\equiv 4 \\pmod{15}$\n$x \\equiv 1 \\pmod{2}$", + "Output Answer": [ + "$199$" + ], + "Output Program": [ + "constraints = (3, 14), (4, 15), (1, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 14), (4, 15), (1, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10641)$.", + "Output Answer": [ + "$7092$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10641))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15258 \\pmod{93}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(15258 % 93)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.798$ to base $9$.", + "Output Answer": [ + "$0.715661_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.798\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $282$ is divisible by $3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(282 % 3 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2464)$.", + "Output Answer": [ + "$960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2464))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{167}{112}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{224} \\left(\\sqrt{78065}-167\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(167/112)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-35,-757\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -35, -757\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42488)$.", + "Output Answer": [ + "$20608$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42488))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1667^1101 \\pmod{2503}$.", + "Output Answer": [ + "$1351$" + ], + "Output Program": [ + "print(pow(1667, 1101, 2503))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $487^m \\equiv 1 \\pmod{756}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(487, 756))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{975,947,555\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 975, 947, 555\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{368}{609}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{609} \\left(\\sqrt{404737}-184\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(368/609)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n8663", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(8663))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 15 \\pmod{12}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 5), (15, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 5), (15, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 5), (15, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1669x \\equiv 1 \\pmod{2146}$.", + "Output Answer": [ + "$2137$" + ], + "Output Program": [ + "print(pow(1669, -1, 2146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-656,195,221\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -656, 195, 221\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1119^1612 \\pmod{2815}$.", + "Output Answer": [ + "$706$" + ], + "Output Program": [ + "print(pow(1119, 1612, 2815))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6978)$.", + "Output Answer": [ + "$2324$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6978))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $123x \\equiv 1 \\pmod{1048}$.", + "Output Answer": [ + "$835$" + ], + "Output Program": [ + "print(pow(123, -1, 1048))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{386,-119,665\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 386, -119, 665\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $15406$.", + "Output Answer": [ + "$\\{5,11,13,15,29,33,35,39,43,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(15406):\n if len(roots) == 10: break\n if gcd(a, 15406) == 1 and is_primitive_root(a, 15406):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $693x \\equiv 1 \\pmod{2258}$.", + "Output Answer": [ + "$883$" + ], + "Output Program": [ + "print(pow(693, -1, 2258))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2013 \\pmod{11}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(2013 % 11)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56181 \\pmod{61}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(56181 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2004^1027 \\pmod{2665}$.", + "Output Answer": [ + "$349$" + ], + "Output Program": [ + "print(pow(2004, 1027, 2665))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{282}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 282))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $694$.", + "Output Answer": [ + "$\\{5,7,15,17,19,21,23,37,41,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(694):\n if len(roots) == 10: break\n if gcd(a, 694) == 1 and is_primitive_root(a, 694):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96539 \\pmod{94}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(96539 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8938 \\pmod{39}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(8938 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83036 \\pmod{11}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(83036 % 11)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{328}{81}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{81} \\left(\\sqrt{33457}-164\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(328/81)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18408)$.", + "Output Answer": [ + "$5568$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18408))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n10485", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10485))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $180^m \\equiv 1 \\pmod{191}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(180, 191))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $114^m \\equiv 1 \\pmod{877}$.", + "Output Answer": [ + "$438$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(114, 877))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $169x \\equiv 1 \\pmod{218}$.", + "Output Answer": [ + "$129$" + ], + "Output Program": [ + "print(pow(169, -1, 218))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44313)$.", + "Output Answer": [ + "$29540$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44313))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n92789", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(92789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{626,-732\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 626, -732\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n35355", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(35355))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $222^1891 \\pmod{2856}$.", + "Output Answer": [ + "$936$" + ], + "Output Program": [ + "print(pow(222, 1891, 2856))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n9691", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9691))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50344 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(50344 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 15), (1, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 15), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 15), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $27408$.", + "Output Answer": [ + "$2^4\\cdot 3^1\\cdot 571^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(27408))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $2858$.", + "Output Answer": [ + "$\\{11,29,33,47,53,77,79,87,93,97\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(2858):\n if len(roots) == 10: break\n if gcd(a, 2858) == 1 and is_primitive_root(a, 2858):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $906^2015 \\pmod{1456}$.", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "print(pow(906, 2015, 1456))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $27^m \\equiv 1 \\pmod{98}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(27, 98))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11175)$.", + "Output Answer": [ + "$5920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11175))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{234}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 234))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{19}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "import math\n\nconstraints = (12, 19), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 19), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 19), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{19}$\n$x \\equiv 10 \\pmod{6}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$544$" + ], + "Output Program": [ + "constraints = (12, 19), (10, 6), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 19), (10, 6), (11, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 19), (10, 6), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1086^71 \\pmod{1245}$.", + "Output Answer": [ + "$546$" + ], + "Output Program": [ + "print(pow(1086, 71, 1245))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n102409", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102409))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41517)$.", + "Output Answer": [ + "$23688$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41517))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $999^1168 \\pmod{2789}$.", + "Output Answer": [ + "$661$" + ], + "Output Program": [ + "print(pow(999, 1168, 2789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13122)$.", + "Output Answer": [ + "$4374$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13122))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2214^2023 \\pmod{2740}$.", + "Output Answer": [ + "$684$" + ], + "Output Program": [ + "print(pow(2214, 2023, 2740))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{816}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 816))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71349", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71349))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{177}{5623}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{126503845}-177}{11246}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(177/5623)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1545x \\equiv 1 \\pmod{1981}$.", + "Output Answer": [ + "$1095$" + ], + "Output Program": [ + "print(pow(1545, -1, 1981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23731 \\pmod{53}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(23731 % 53)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2004^400 \\pmod{2443}$.", + "Output Answer": [ + "$492$" + ], + "Output Program": [ + "print(pow(2004, 400, 2443))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59740 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(59740 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-106,296\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -106, 296\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1707^1897 \\pmod{2007}$.", + "Output Answer": [ + "$612$" + ], + "Output Program": [ + "print(pow(1707, 1897, 2007))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72610 \\pmod{44}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(72610 % 44)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1459^65 \\pmod{1523}$.", + "Output Answer": [ + "$1354$" + ], + "Output Program": [ + "print(pow(1459, 65, 1523))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45936)$.", + "Output Answer": [ + "$13440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27049}{10548}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1176689617}-27049}{21096}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27049/10548)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $475^m \\equiv 1 \\pmod{656}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(475, 656))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-35682$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-35682 % -38 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{685,-887,-268\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 685, -887, -268\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $35^m \\equiv 1 \\pmod{103}$.", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(35, 103))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2139}{725}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6677821}-2139}{1450}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2139/725)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-261,-291\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = -261, -291\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $322x \\equiv 1 \\pmod{535}$.", + "Output Answer": [ + "$108$" + ], + "Output Program": [ + "print(pow(322, -1, 535))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $642^m \\equiv 1 \\pmod{785}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(642, 785))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10817)$.", + "Output Answer": [ + "$10416$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10817))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35150)$.", + "Output Answer": [ + "$12960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35150))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22483}{4600}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{590125289}-22483}{9200}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22483/4600)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{213}{1630}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10672969}-213}{3260}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(213/1630)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $721x \\equiv 1 \\pmod{766}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(721, -1, 766))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $131x \\equiv 1 \\pmod{564}$.", + "Output Answer": [ + "$155$" + ], + "Output Program": [ + "print(pow(131, -1, 564))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $965x \\equiv 1 \\pmod{2492}$.", + "Output Answer": [ + "$909$" + ], + "Output Program": [ + "print(pow(965, -1, 2492))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1499}{5830}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{138202601}-1499}{11660}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1499/5830)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $11x \\equiv 1 \\pmod{710}$.", + "Output Answer": [ + "$581$" + ], + "Output Program": [ + "print(pow(11, -1, 710))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2414^1263 \\pmod{2804}$.", + "Output Answer": [ + "$2424$" + ], + "Output Program": [ + "print(pow(2414, 1263, 2804))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1051x \\equiv 1 \\pmod{1984}$.", + "Output Answer": [ + "$723$" + ], + "Output Program": [ + "print(pow(1051, -1, 1984))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56216 \\pmod{69}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(56216 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42398)$.", + "Output Answer": [ + "$18816$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42398))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n82073", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82073))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $193$ to base $5$.", + "Output Answer": [ + "$1233_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 193\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1160^64 \\pmod{2117}$.", + "Output Answer": [ + "$957$" + ], + "Output Program": [ + "print(pow(1160, 64, 2117))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 20 \\pmod{8}$\n$x \\equiv 10 \\pmod{14}$", + "Output Answer": [ + "$276$" + ], + "Output Program": [ + "constraints = (4, 17), (20, 8), (10, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 17), (20, 8), (10, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8031}{23270}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2230468561}-8031}{46540}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8031/23270)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{10}$\n$x \\equiv 20 \\pmod{3}$\n$x \\equiv 0 \\pmod{11}$", + "Output Answer": [ + "$209$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 10), (20, 3), (0, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 10), (20, 3), (0, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (19, 10), (20, 3), (0, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $156^852 \\pmod{2475}$.", + "Output Answer": [ + "$2061$" + ], + "Output Program": [ + "print(pow(156, 852, 2475))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $361^m \\equiv 1 \\pmod{516}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(361, 516))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $30x \\equiv 1 \\pmod{91}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "print(pow(30, -1, 91))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{14}$\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 7 \\pmod{13}$", + "Output Answer": [ + "$1840$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 14), (10, 5), (16, 3), (7, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 14), (10, 5), (16, 3), (7, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 14), (10, 5), (16, 3), (7, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{706,-581\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 706, -581\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-6574$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6574 % -19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-734,-591\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -734, -591\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1237x \\equiv 1 \\pmod{1662}$.", + "Output Answer": [ + "$481$" + ], + "Output Program": [ + "print(pow(1237, -1, 1662))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{40194}{7873}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{465873538}-20097}{7873}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(40194/7873)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$274$" + ], + "Output Program": [ + "print(pow(79, -1, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{367}{1290}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6791089}-367}{2580}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(367/1290)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $654x \\equiv 1 \\pmod{2105}$.", + "Output Answer": [ + "$1104$" + ], + "Output Program": [ + "print(pow(654, -1, 2105))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{11}$\n$x \\equiv 10 \\pmod{6}$\n$x \\equiv 20 \\pmod{19}$\n$x \\equiv 4 \\pmod{3}$", + "Output Answer": [ + "$742$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 11), (10, 6), (20, 19), (4, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 11), (10, 6), (20, 19), (4, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{6}$\n$x \\equiv 14 \\pmod{8}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (18, 6), (14, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 6), (14, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $39173$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(39173 % -43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $182^m \\equiv 1 \\pmod{365}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(182, 365))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 95461 \\pmod{16}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(95461 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8877)$.", + "Output Answer": [ + "$5360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8877))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-41,144,659\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -41, 144, 659\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{496,653,758\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 496, 653, 758\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1647^342 \\pmod{2421}$.", + "Output Answer": [ + "$720$" + ], + "Output Program": [ + "print(pow(1647, 342, 2421))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{191,389\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 191, 389\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71631", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71631))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $314^m \\equiv 1 \\pmod{345}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(314, 345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $37^m \\equiv 1 \\pmod{716}$.", + "Output Answer": [ + "$178$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(37, 716))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n39825", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(39825))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2393^1874 \\pmod{2813}$.", + "Output Answer": [ + "$2382$" + ], + "Output Program": [ + "print(pow(2393, 1874, 2813))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n16221", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53161", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53161))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13045)$.", + "Output Answer": [ + "$10432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13045))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 9 \\pmod{2}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (4, 5), (9, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 5), (9, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 5), (9, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8017$.", + "Output Answer": [ + "$\\{5,10,19,30,34,38,40,41,43,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8017):\n if len(roots) == 10: break\n if gcd(a, 8017) == 1 and is_primitive_root(a, 8017):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $229x \\equiv 1 \\pmod{354}$.", + "Output Answer": [ + "$337$" + ], + "Output Program": [ + "print(pow(229, -1, 354))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $310x \\equiv 1 \\pmod{1419}$.", + "Output Answer": [ + "$325$" + ], + "Output Program": [ + "print(pow(310, -1, 1419))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41649)$.", + "Output Answer": [ + "$27764$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41649))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{915,379,-166\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 915, 379, -166\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53995", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53995))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $35^m \\equiv 1 \\pmod{162}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(35, 162))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1242$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1242 % -18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $397^m \\equiv 1 \\pmod{648}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(397, 648))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{40,-188\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 40, -188\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $643x \\equiv 1 \\pmod{716}$.", + "Output Answer": [ + "$255$" + ], + "Output Program": [ + "print(pow(643, -1, 716))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{9}$\n$x \\equiv 8 \\pmod{7}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 9), (8, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 9), (8, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 9), (8, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $129^m \\equiv 1 \\pmod{284}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(129, 284))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41463)$.", + "Output Answer": [ + "$25920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41463))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7807}{22166}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2026275473}-7807}{44332}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7807/22166)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $333^1042 \\pmod{2261}$.", + "Output Answer": [ + "$270$" + ], + "Output Program": [ + "print(pow(333, 1042, 2261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $327x \\equiv 1 \\pmod{1936}$.", + "Output Answer": [ + "$1415$" + ], + "Output Program": [ + "print(pow(327, -1, 1936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 6 \\pmod{16}$\n$x \\equiv 0 \\pmod{3}$\n$x \\equiv 3 \\pmod{19}$", + "Output Answer": [ + "$630$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 3), (6, 16), (0, 3), (3, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 3), (6, 16), (0, 3), (3, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47827)$.", + "Output Answer": [ + "$43992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47827))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1914^759 \\pmod{2943}$.", + "Output Answer": [ + "$1242$" + ], + "Output Program": [ + "print(pow(1914, 759, 2943))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1372x \\equiv 1 \\pmod{2377}$.", + "Output Answer": [ + "$421$" + ], + "Output Program": [ + "print(pow(1372, -1, 2377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82653 \\pmod{38}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(82653 % 38)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $549x \\equiv 1 \\pmod{1150}$.", + "Output Answer": [ + "$199$" + ], + "Output Program": [ + "print(pow(549, -1, 1150))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $468x \\equiv 1 \\pmod{1225}$.", + "Output Answer": [ + "$657$" + ], + "Output Program": [ + "print(pow(468, -1, 1225))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $617x \\equiv 1 \\pmod{1824}$.", + "Output Answer": [ + "$473$" + ], + "Output Program": [ + "print(pow(617, -1, 1824))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.58$ to base $31$.", + "Output Answer": [ + "$\\text{0.hubo}_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.58\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $259^m \\equiv 1 \\pmod{921}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(259, 921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2212122_3$ to base 10.", + "Output Answer": [ + "$2096$" + ], + "Output Program": [ + "n = '2212122'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{405,136,75\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 405, 136, 75\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-120,199,29\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -120, 199, 29\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 3 \\pmod{6}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 5), (3, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 5), (3, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 5), (3, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36006 \\pmod{28}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(36006 % 28)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14804}{11617}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{189744293}-7402}{11617}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14804/11617)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $176_{36}$ to base 10.", + "Output Answer": [ + "$1554$" + ], + "Output Program": [ + "n = '176'.strip('.')\nbase = 36\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $857^1445 \\pmod{2417}$.", + "Output Answer": [ + "$1869$" + ], + "Output Program": [ + "print(pow(857, 1445, 2417))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{24307}{30169}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4231504493}-24307}{60338}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24307/30169)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 18 \\pmod{19}$", + "Output Answer": [ + "$4407$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 2), (0, 13), (15, 9), (18, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 2), (0, 13), (15, 9), (18, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 2), (0, 13), (15, 9), (18, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8357)$.", + "Output Answer": [ + "$8160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $407x \\equiv 1 \\pmod{711}$.", + "Output Answer": [ + "$428$" + ], + "Output Program": [ + "print(pow(407, -1, 711))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 81104 \\pmod{94}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "print(81104 % 94)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33638 \\pmod{25}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(33638 % 25)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1451^2322 \\pmod{1782}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(1451, 2322, 1782))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{820}{1443}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2250349}-410}{1443}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(820/1443)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $23x \\equiv 1 \\pmod{1008}$.", + "Output Answer": [ + "$263$" + ], + "Output Program": [ + "print(pow(23, -1, 1008))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19897)$.", + "Output Answer": [ + "$19600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19897))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $874^153 \\pmod{1601}$.", + "Output Answer": [ + "$735$" + ], + "Output Program": [ + "print(pow(874, 153, 1601))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{14}$\n$x \\equiv 14 \\pmod{11}$", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "constraints = (12, 14), (14, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 14), (14, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 14), (14, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13392}{21695}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{515509441}-6696}{21695}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13392/21695)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36443 \\pmod{12}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(36443 % 12)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48054 \\pmod{24}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(48054 % 24)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1395^2464 \\pmod{2548}$.", + "Output Answer": [ + "$373$" + ], + "Output Program": [ + "print(pow(1395, 2464, 2548))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1888^341 \\pmod{2356}$.", + "Output Answer": [ + "$1816$" + ], + "Output Program": [ + "print(pow(1888, 341, 2356))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{68}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 68))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34515)$.", + "Output Answer": [ + "$16704$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34515))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.34$ to base $35$.", + "Output Answer": [ + "$\\text{0.bvhh}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.34\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n33887", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33887))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2197^663 \\pmod{2990}$.", + "Output Answer": [ + "$923$" + ], + "Output Program": [ + "print(pow(2197, 663, 2990))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21311)$.", + "Output Answer": [ + "$21000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21311))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16752}{12397}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{223842985}-8376}{12397}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16752/12397)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{18}$\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 0 \\pmod{3}$", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "constraints = (18, 18), (19, 13), (0, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 18), (19, 13), (0, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $32x \\equiv 1 \\pmod{519}$.", + "Output Answer": [ + "$146$" + ], + "Output Program": [ + "print(pow(32, -1, 519))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3131}{2426}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{33345065}-3131}{4852}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3131/2426)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32247)$.", + "Output Answer": [ + "$21492$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32247))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11191}{1565}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{135035381}-11191}{3130}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11191/1565)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $22x \\equiv 1 \\pmod{43}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(pow(22, -1, 43))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{869}{205}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{410} \\left(\\sqrt{923261}-869\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(869/205)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-689,549\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -689, 549\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38911)$.", + "Output Answer": [ + "$38512$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38911))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $249$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(249 % -40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{179,-182,409\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 179, -182, 409\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23173)$.", + "Output Answer": [ + "$23172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23173))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n74827", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(74827))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{41}{15376}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{945687185}-41}{30752}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(41/15376)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $831x \\equiv 1 \\pmod{889}$.", + "Output Answer": [ + "$843$" + ], + "Output Program": [ + "print(pow(831, -1, 889))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75559 \\pmod{40}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(75559 % 40)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $58538$.", + "Output Answer": [ + "$\\{13,17,29,37,39,47,51,65,67,71\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(58538):\n if len(roots) == 10: break\n if gcd(a, 58538) == 1 and is_primitive_root(a, 58538):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 3 \\pmod{6}$\n$x \\equiv 11 \\pmod{8}$\n$x \\equiv 5 \\pmod{13}$", + "Output Answer": [ + "$2475$" + ], + "Output Program": [ + "constraints = (11, 11), (3, 6), (11, 8), (5, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 11), (3, 6), (11, 8), (5, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15907 \\pmod{16}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(15907 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{686,872,-987\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 686, 872, -987\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10849}{31120}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3991518401}-10849}{62240}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10849/31120)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $2^m \\equiv 1 \\pmod{217}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(2, 217))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $987x \\equiv 1 \\pmod{2176}$.", + "Output Answer": [ + "$851$" + ], + "Output Program": [ + "print(pow(987, -1, 2176))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-8814$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-8814 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-274,487\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -274, 487\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $27x \\equiv 1 \\pmod{980}$.", + "Output Answer": [ + "$363$" + ], + "Output Program": [ + "print(pow(27, -1, 980))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2298)$.", + "Output Answer": [ + "$764$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2298))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{18}$\n$x \\equiv 11 \\pmod{10}$", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 18), (11, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 18), (11, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8482$.", + "Output Answer": [ + "$\\{3,27,35,39,47,51,55,57,59,63\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8482):\n if len(roots) == 10: break\n if gcd(a, 8482) == 1 and is_primitive_root(a, 8482):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{277,-686,-288\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 277, -686, -288\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31016)$.", + "Output Answer": [ + "$15504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31016))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10995}{9349}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{470505229}-10995}{18698}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10995/9349)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28896)$.", + "Output Answer": [ + "$8064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28896))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12033}{361}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{722} \\left(\\sqrt{145314373}-12033\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12033/361)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22485)$.", + "Output Answer": [ + "$11984$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22485))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8098}{7317}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{69932890}-4049}{7317}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8098/7317)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $379x \\equiv 1 \\pmod{1672}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "print(pow(379, -1, 1672))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 12 \\pmod{2}$", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (6, 15), (16, 8), (12, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 7), (6, 15), (16, 8), (12, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 20 \\pmod{6}$\n$x \\equiv 19 \\pmod{13}$", + "Output Answer": [ + "$188$" + ], + "Output Program": [ + "constraints = (12, 11), (20, 6), (19, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 11), (20, 6), (19, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 11), (20, 6), (19, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $83^m \\equiv 1 \\pmod{152}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(83, 152))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-699,-740\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -699, -740\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1026x \\equiv 1 \\pmod{1253}$.", + "Output Answer": [ + "$1115$" + ], + "Output Program": [ + "print(pow(1026, -1, 1253))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $202^m \\equiv 1 \\pmod{981}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(202, 981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $575^1601 \\pmod{642}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "print(pow(575, 1601, 642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1154^1938 \\pmod{1914}$.", + "Output Answer": [ + "$430$" + ], + "Output Program": [ + "print(pow(1154, 1938, 1914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{15}$\n$x \\equiv 7 \\pmod{14}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "constraints = (20, 15), (7, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 15), (7, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (20, 15), (7, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1135x \\equiv 1 \\pmod{2179}$.", + "Output Answer": [ + "$1317$" + ], + "Output Program": [ + "print(pow(1135, -1, 2179))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{786,0\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 786, 0\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1737}{3535}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{53002069}-1737}{7070}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1737/3535)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{808,-653\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 808, -653\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $106^m \\equiv 1 \\pmod{309}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(106, 309))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{17}$\n$x \\equiv 3 \\pmod{3}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "constraints = (19, 17), (3, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (19, 17), (3, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 17), (3, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n22777", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(22777))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3862}{523}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{523} \\left(\\sqrt{4002290}-1931\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3862/523)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13534}{10843}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{163362938}-6767}{10843}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13534/10843)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1052x \\equiv 1 \\pmod{2437}$.", + "Output Answer": [ + "$322$" + ], + "Output Program": [ + "print(pow(1052, -1, 2437))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n2753", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{2}$\n$x \\equiv 6 \\pmod{14}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (14, 2), (6, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 2), (6, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56403 \\pmod{61}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(56403 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n98445", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(98445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $966$ to base $12$.", + "Output Answer": [ + "$686_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 966\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $117^m \\equiv 1 \\pmod{241}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(117, 241))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $586x \\equiv 1 \\pmod{2159}$.", + "Output Answer": [ + "$2089$" + ], + "Output Program": [ + "print(pow(586, -1, 2159))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-590,902,377\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -590, 902, 377\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24529)$.", + "Output Answer": [ + "$23220$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24529))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2851$ to base $18$.", + "Output Answer": [ + "$\\text{8e7}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2851\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $798$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(798 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{247,670,-320\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 247, 670, -320\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $978^928 \\pmod{1146}$.", + "Output Answer": [ + "$618$" + ], + "Output Program": [ + "print(pow(978, 928, 1146))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $175^m \\equiv 1 \\pmod{478}$.", + "Output Answer": [ + "$238$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(175, 478))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $84^m \\equiv 1 \\pmod{655}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(84, 655))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $251^m \\equiv 1 \\pmod{664}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(251, 664))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39086)$.", + "Output Answer": [ + "$19542$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39086))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61571 \\pmod{63}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(61571 % 63)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $5859$ is divisible by $21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5859 % 21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $211x \\equiv 1 \\pmod{341}$.", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "print(pow(211, -1, 341))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-5,1,-5,0\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = -5, 1, -5, 0\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1626}{29921}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{895927210}-813}{29921}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1626/29921)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28621)$.", + "Output Answer": [ + "$28620$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28621))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12165}{9596}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{516320089}-12165}{19192}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12165/9596)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17579}{16343}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1377395837}-17579}{32686}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17579/16343)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{36297}{9358}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1667760865}-36297}{18716}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36297/9358)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{15}$\n$x \\equiv 20 \\pmod{3}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "constraints = (11, 15), (20, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 15), (20, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $431$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(431 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{820,91\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 820, 91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $481x \\equiv 1 \\pmod{1632}$.", + "Output Answer": [ + "$1537$" + ], + "Output Program": [ + "print(pow(481, -1, 1632))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{167}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 167))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $333^1431 \\pmod{800}$.", + "Output Answer": [ + "$517$" + ], + "Output Program": [ + "print(pow(333, 1431, 800))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $54x \\equiv 1 \\pmod{491}$.", + "Output Answer": [ + "$391$" + ], + "Output Program": [ + "print(pow(54, -1, 491))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41577)$.", + "Output Answer": [ + "$27716$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41577))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{39,896,817\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 39, 896, 817\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-43056$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-43056 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $9630$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9630 % 15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6022)$.", + "Output Answer": [ + "$3010$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6022))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n13689", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(13689))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1598$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1598 % -34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1644x \\equiv 1 \\pmod{1853}$.", + "Output Answer": [ + "$860$" + ], + "Output Program": [ + "print(pow(1644, -1, 1853))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78550 \\pmod{98}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(78550 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $56^m \\equiv 1 \\pmod{83}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(56, 83))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $287x \\equiv 1 \\pmod{900}$.", + "Output Answer": [ + "$323$" + ], + "Output Program": [ + "print(pow(287, -1, 900))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2456^380 \\pmod{2476}$.", + "Output Answer": [ + "$1644$" + ], + "Output Program": [ + "print(pow(2456, 380, 2476))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1397x \\equiv 1 \\pmod{2248}$.", + "Output Answer": [ + "$597$" + ], + "Output Program": [ + "print(pow(1397, -1, 2248))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{15}$\n$x \\equiv 1 \\pmod{14}$", + "Output Answer": [ + "$197$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 15), (1, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 15), (1, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 15), (1, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10367)$.", + "Output Answer": [ + "$8880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10367))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{5}$\n$x \\equiv 14 \\pmod{4}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 5), (14, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 5), (14, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 5), (14, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{267,17,18\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 267, 17, 18\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7232)$.", + "Output Answer": [ + "$3584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7232))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{633,734\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 633, 734\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 7 \\pmod{16}$", + "Output Answer": [ + "$87$" + ], + "Output Program": [ + "constraints = (9, 13), (7, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 13), (7, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (7, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1373$ is divisible by $41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1373 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1104^723 \\pmod{2161}$.", + "Output Answer": [ + "$829$" + ], + "Output Program": [ + "print(pow(1104, 723, 2161))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4818 \\pmod{41}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(4818 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1749^1316 \\pmod{2500}$.", + "Output Answer": [ + "$2001$" + ], + "Output Program": [ + "print(pow(1749, 1316, 2500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19316)$.", + "Output Answer": [ + "$8760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19316))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13732}{9003}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{128195965}-6866}{9003}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13732/9003)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35263 \\pmod{52}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(35263 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{102,-641,607\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 102, -641, 607\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $60688$.", + "Output Answer": [ + "$2^4\\cdot 3793^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(60688))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35665)$.", + "Output Answer": [ + "$24432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35665))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $94921$.", + "Output Answer": [ + "$23^1\\cdot 4127^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(94921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{431,-925\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 431, -925\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9836}{6433}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{65570213}-4918}{6433}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9836/6433)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-524,887\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -524, 887\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47235)$.", + "Output Answer": [ + "$24288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47235))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,2\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -1, 2\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n17981", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(17981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6801)$.", + "Output Answer": [ + "$4532$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6801))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5780)$.", + "Output Answer": [ + "$2176$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $762^m \\equiv 1 \\pmod{763}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(762, 763))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1686^449 \\pmod{2013}$.", + "Output Answer": [ + "$1500$" + ], + "Output Program": [ + "print(pow(1686, 449, 2013))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2127^1159 \\pmod{2249}$.", + "Output Answer": [ + "$1240$" + ], + "Output Program": [ + "print(pow(2127, 1159, 2249))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{7}$\n$x \\equiv 6 \\pmod{8}$", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 7), (6, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 7), (6, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 7), (6, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71482 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(71482 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30009)$.", + "Output Answer": [ + "$17136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30009))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2330^1007 \\pmod{2948}$.", + "Output Answer": [ + "$1720$" + ], + "Output Program": [ + "print(pow(2330, 1007, 2948))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4867}{5195}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{455501}-4867}{10390}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4867/5195)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $294x \\equiv 1 \\pmod{967}$.", + "Output Answer": [ + "$273$" + ], + "Output Program": [ + "print(pow(294, -1, 967))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32279 \\pmod{100}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "print(32279 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{290,106\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 290, 106\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-369,79,205\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -369, 79, 205\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1052}{963}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{963} \\left(\\sqrt{1204045}-526\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1052/963)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $22$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(22 % -22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5877}{4393}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{4469317}-5877}{8786}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5877/4393)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $109x \\equiv 1 \\pmod{1528}$.", + "Output Answer": [ + "$757$" + ], + "Output Program": [ + "print(pow(109, -1, 1528))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 4 \\pmod{4}$", + "Output Answer": [ + "$832$" + ], + "Output Program": [ + "constraints = (16, 17), (0, 13), (4, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 17), (0, 13), (4, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 17), (0, 13), (4, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-7856$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7856 % 16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n101483", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1610^982 \\pmod{2764}$.", + "Output Answer": [ + "$2456$" + ], + "Output Program": [ + "print(pow(1610, 982, 2764))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30065 \\pmod{49}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(30065 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-414$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-414 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $189^m \\equiv 1 \\pmod{404}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(189, 404))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1203x \\equiv 1 \\pmod{1324}$.", + "Output Answer": [ + "$755$" + ], + "Output Program": [ + "print(pow(1203, -1, 1324))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1869^2027 \\pmod{2740}$.", + "Output Answer": [ + "$389$" + ], + "Output Program": [ + "print(pow(1869, 2027, 2740))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2410^149 \\pmod{2860}$.", + "Output Answer": [ + "$980$" + ], + "Output Program": [ + "print(pow(2410, 149, 2860))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6379}{14271}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{2959645}-6379}{28542}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6379/14271)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $30143$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(30143 % 43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{324,250,241\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 324, 250, 241\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $312^m \\equiv 1 \\pmod{803}$.", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(312, 803))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 6 \\pmod{12}$", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 17), (6, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 17), (6, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 17), (6, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-345$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-345 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3433 \\pmod{60}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(3433 % 60)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{123}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 123))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35594)$.", + "Output Answer": [ + "$15984$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35594))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $562^996 \\pmod{1765}$.", + "Output Answer": [ + "$1291$" + ], + "Output Program": [ + "print(pow(562, 996, 1765))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $15859$.", + "Output Answer": [ + "$\\{2,10,12,15,18,22,23,28,31,32\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(15859):\n if len(roots) == 10: break\n if gcd(a, 15859) == 1 and is_primitive_root(a, 15859):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{107}{132}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{264} \\left(\\sqrt{81145}-107\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(107/132)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-6318$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-6318 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $55500$.", + "Output Answer": [ + "$2^2\\cdot 3^1\\cdot 5^3\\cdot 37^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(55500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36194)$.", + "Output Answer": [ + "$18096$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36194))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58357 \\pmod{23}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(58357 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $784^780 \\pmod{2080}$.", + "Output Answer": [ + "$2016$" + ], + "Output Program": [ + "print(pow(784, 780, 2080))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14391)$.", + "Output Answer": [ + "$8640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $479^m \\equiv 1 \\pmod{986}$.", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(479, 986))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23155 \\pmod{47}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(23155 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $47520$ is divisible by $36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(47520 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 14 \\pmod{10}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 11), (14, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 11), (14, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 11), (14, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $176^m \\equiv 1 \\pmod{417}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(176, 417))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-768,24\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -768, 24\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $62x \\equiv 1 \\pmod{599}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(pow(62, -1, 599))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{214,-57\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 214, -57\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1804x \\equiv 1 \\pmod{2235}$.", + "Output Answer": [ + "$1369$" + ], + "Output Program": [ + "print(pow(1804, -1, 2235))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{7}$\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 12 \\pmod{5}$", + "Output Answer": [ + "$317$" + ], + "Output Program": [ + "constraints = (2, 7), (20, 11), (12, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 7), (20, 11), (12, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 7), (20, 11), (12, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $22^m \\equiv 1 \\pmod{45}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(22, 45))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85931 \\pmod{45}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(85931 % 45)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.978$ to base $8$.", + "Output Answer": [ + "$0.7645707_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.978\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $253^m \\equiv 1 \\pmod{940}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(253, 940))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2311$ to base $16$.", + "Output Answer": [ + "$907_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2311\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $88x \\equiv 1 \\pmod{129}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(pow(88, -1, 129))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2466^2047 \\pmod{2784}$.", + "Output Answer": [ + "$1248$" + ], + "Output Program": [ + "print(pow(2466, 2047, 2784))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n76089", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76089))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $581x \\equiv 1 \\pmod{1032}$.", + "Output Answer": [ + "$389$" + ], + "Output Program": [ + "print(pow(581, -1, 1032))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25679 \\pmod{57}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(25679 % 57)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $282^m \\equiv 1 \\pmod{481}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(282, 481))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 3 \\pmod{12}$\n$x \\equiv 0 \\pmod{13}$", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 5), (3, 12), (0, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 5), (3, 12), (0, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 5), (3, 12), (0, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14534)$.", + "Output Answer": [ + "$6552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14534))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $297^396 \\pmod{2782}$.", + "Output Answer": [ + "$2653$" + ], + "Output Program": [ + "print(pow(297, 396, 2782))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $173^m \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(173, 322))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $139x \\equiv 1 \\pmod{1020}$.", + "Output Answer": [ + "$499$" + ], + "Output Program": [ + "print(pow(139, -1, 1020))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18306)$.", + "Output Answer": [ + "$6048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18306))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7797}{21955}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1988881309}-7797}{43910}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7797/21955)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n41299", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(41299))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45886)$.", + "Output Answer": [ + "$22942$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45886))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $19500$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(19500 % 25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19419)$.", + "Output Answer": [ + "$12944$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19419))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1499^227 \\pmod{2914}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(pow(1499, 227, 2914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-21096$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-21096 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{15}$\n$x \\equiv 20 \\pmod{17}$\n$x \\equiv 4 \\pmod{13}$", + "Output Answer": [ + "$394$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 15), (20, 17), (4, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 15), (20, 17), (4, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 15), (20, 17), (4, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-442,103,-320\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -442, 103, -320\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1889^1119 \\pmod{2500}$.", + "Output Answer": [ + "$1809$" + ], + "Output Program": [ + "print(pow(1889, 1119, 2500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $509^m \\equiv 1 \\pmod{548}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(509, 548))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83182 \\pmod{41}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(83182 % 41)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $266x \\equiv 1 \\pmod{1801}$.", + "Output Answer": [ + "$1063$" + ], + "Output Program": [ + "print(pow(266, -1, 1801))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1869^1717 \\pmod{2781}$.", + "Output Answer": [ + "$2322$" + ], + "Output Program": [ + "print(pow(1869, 1717, 2781))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49788 \\pmod{82}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(49788 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{18}$\n$x \\equiv 3 \\pmod{4}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 18), (3, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 18), (3, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $3861$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3861 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $51552$.", + "Output Answer": [ + "$2^5\\cdot 3^2\\cdot 179^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(51552))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2262x \\equiv 1 \\pmod{2309}$.", + "Output Answer": [ + "$393$" + ], + "Output Program": [ + "print(pow(2262, -1, 2309))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6701}{1151}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{50202605}-6701}{2302}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6701/1151)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1329x \\equiv 1 \\pmod{1720}$.", + "Output Answer": [ + "$849$" + ], + "Output Program": [ + "print(pow(1329, -1, 1720))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $248x \\equiv 1 \\pmod{1297}$.", + "Output Answer": [ + "$455$" + ], + "Output Program": [ + "print(pow(248, -1, 1297))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27362}{26187}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{872928730}-13681}{26187}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27362/26187)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n47139", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(47139))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{684}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 684))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 5 \\pmod{20}$\n$x \\equiv 7 \\pmod{19}$", + "Output Answer": [ + "$1565$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 17), (5, 20), (7, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 17), (5, 20), (7, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 17), (5, 20), (7, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19568)$.", + "Output Answer": [ + "$9776$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19568))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45332 \\pmod{3}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(45332 % 3)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-845,134,-711\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -845, 134, -711\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1573x \\equiv 1 \\pmod{2186}$.", + "Output Answer": [ + "$189$" + ], + "Output Program": [ + "print(pow(1573, -1, 2186))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97129", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97129))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{8}$\n$x \\equiv 17 \\pmod{14}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 8), (17, 14), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 8), (17, 14), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $171^m \\equiv 1 \\pmod{358}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(171, 358))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1475^489 \\pmod{2605}$.", + "Output Answer": [ + "$470$" + ], + "Output Program": [ + "print(pow(1475, 489, 2605))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1774^1599 \\pmod{2054}$.", + "Output Answer": [ + "$554$" + ], + "Output Program": [ + "print(pow(1774, 1599, 2054))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-904,-934\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -904, -934\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-532,-241,688\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -532, -241, 688\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55381 \\pmod{44}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(55381 % 44)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $21242$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(21242 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43346)$.", + "Output Answer": [ + "$21672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43346))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{20}$\n$x \\equiv 20 \\pmod{7}$\n$x \\equiv 12 \\pmod{18}$", + "Output Answer": [ + "$930$" + ], + "Output Program": [ + "constraints = (10, 20), (20, 7), (12, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 20), (20, 7), (12, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1816}{3435}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{12623689}-908}{3435}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1816/3435)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $93^m \\equiv 1 \\pmod{145}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(93, 145))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96567 \\pmod{92}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(96567 % 92)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n50973", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50973))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2133)$.", + "Output Answer": [ + "$1404$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2133))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $749^324 \\pmod{2843}$.", + "Output Answer": [ + "$1263$" + ], + "Output Program": [ + "print(pow(749, 324, 2843))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15427)$.", + "Output Answer": [ + "$15426$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15427))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-420,142,-215\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -420, 142, -215\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $41^1566 \\pmod{244}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(pow(41, 1566, 244))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $67x \\equiv 1 \\pmod{812}$.", + "Output Answer": [ + "$303$" + ], + "Output Program": [ + "print(pow(67, -1, 812))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-185,353,804\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -185, 353, 804\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{619,732,-590\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 619, 732, -590\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-6,907\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -6, 907\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $155^m \\equiv 1 \\pmod{283}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(155, 283))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27703)$.", + "Output Answer": [ + "$25560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27703))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{957,898,180\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 957, 898, 180\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n31039", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31039))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $705^2421 \\pmod{976}$.", + "Output Answer": [ + "$705$" + ], + "Output Program": [ + "print(pow(705, 2421, 976))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2075x \\equiv 1 \\pmod{2094}$.", + "Output Answer": [ + "$551$" + ], + "Output Program": [ + "print(pow(2075, -1, 2094))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $698^1450 \\pmod{2305}$.", + "Output Answer": [ + "$1564$" + ], + "Output Program": [ + "print(pow(698, 1450, 2305))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $472x \\equiv 1 \\pmod{927}$.", + "Output Answer": [ + "$709$" + ], + "Output Program": [ + "print(pow(472, -1, 927))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4385}{3116}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{58066049}-4385}{6232}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4385/3116)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $805^m \\equiv 1 \\pmod{913}$.", + "Output Answer": [ + "$410$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(805, 913))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{5}$\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 12 \\pmod{18}$", + "Output Answer": [ + "$696$" + ], + "Output Program": [ + "constraints = (1, 5), (3, 11), (12, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 5), (3, 11), (12, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 5), (3, 11), (12, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1861^2 \\pmod{2015}$.", + "Output Answer": [ + "$1551$" + ], + "Output Program": [ + "print(pow(1861, 2, 2015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{25595}{12238}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1254178601}-25595}{24476}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25595/12238)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56164 \\pmod{28}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(56164 % 28)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6420)$.", + "Output Answer": [ + "$1696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6420))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90184 \\pmod{67}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(90184 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $797x \\equiv 1 \\pmod{1436}$.", + "Output Answer": [ + "$409$" + ], + "Output Program": [ + "print(pow(797, -1, 1436))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44745 \\pmod{96}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(44745 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $248$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(248 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7329}{4127}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{121842757}-7329}{8254}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7329/4127)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31171)$.", + "Output Answer": [ + "$25920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31171))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $654$ to base $21$.", + "Output Answer": [ + "$\\text{1a3}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 654\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $765$ to base $15$.", + "Output Answer": [ + "$360_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 765\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1157x \\equiv 1 \\pmod{1214}$.", + "Output Answer": [ + "$1001$" + ], + "Output Program": [ + "print(pow(1157, -1, 1214))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33513 \\pmod{34}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(33513 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51513 \\pmod{46}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(51513 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5681}{8718}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{336287857}-5681}{17436}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5681/8718)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $521^m \\equiv 1 \\pmod{670}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(521, 670))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{18}$\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 4 \\pmod{20}$", + "Output Answer": [ + "$964$" + ], + "Output Program": [ + "constraints = (10, 18), (18, 11), (4, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 18), (18, 11), (4, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $718^m \\equiv 1 \\pmod{981}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(718, 981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1412}{893}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{893} \\left(\\sqrt{1295885}-706\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1412/893)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n33105", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33105))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n101293", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101293))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35162)$.", + "Output Answer": [ + "$17580$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35162))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $399x \\equiv 1 \\pmod{2330}$.", + "Output Answer": [ + "$619$" + ], + "Output Program": [ + "print(pow(399, -1, 2330))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $111^m \\equiv 1 \\pmod{242}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(111, 242))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{187,145,-846\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 187, 145, -846\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6514}{5111}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{36730370}-3257}{5111}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6514/5111)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1242x \\equiv 1 \\pmod{2215}$.", + "Output Answer": [ + "$1828$" + ], + "Output Program": [ + "print(pow(1242, -1, 2215))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1223x \\equiv 1 \\pmod{1546}$.", + "Output Answer": [ + "$1053$" + ], + "Output Program": [ + "print(pow(1223, -1, 1546))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30261)$.", + "Output Answer": [ + "$15600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30261))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{15}$\n$x \\equiv 13 \\pmod{12}$", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "constraints = (7, 15), (13, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 15), (13, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $228$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(228 % -15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-255,323\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -255, 323\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{7}$\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 8 \\pmod{15}$", + "Output Answer": [ + "$368$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 7), (4, 13), (8, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 7), (4, 13), (8, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 7), (4, 13), (8, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-659,173\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -659, 173\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1315x \\equiv 1 \\pmod{1428}$.", + "Output Answer": [ + "$139$" + ], + "Output Program": [ + "print(pow(1315, -1, 1428))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-384,-191\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -384, -191\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $8772$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8772 % -34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23831)$.", + "Output Answer": [ + "$23830$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23831))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{115,274\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 115, 274\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51344 \\pmod{93}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(51344 % 93)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $791^645 \\pmod{2914}$.", + "Output Answer": [ + "$2295$" + ], + "Output Program": [ + "print(pow(791, 645, 2914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-750,377,-506\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -750, 377, -506\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64697 \\pmod{59}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(64697 % 59)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-83,-482\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -83, -482\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n18981", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18981))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9505}{17908}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1373130881}-9505}{35816}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9505/17908)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{598,227\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 598, 227\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $75x \\equiv 1 \\pmod{301}$.", + "Output Answer": [ + "$297$" + ], + "Output Program": [ + "print(pow(75, -1, 301))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{13629}{1747}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{197957677}-13629}{3494}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13629/1747)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-406,151\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -406, 151\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $569^m \\equiv 1 \\pmod{826}$.", + "Output Answer": [ + "$174$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(569, 826))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{19}$\n$x \\equiv 2 \\pmod{8}$", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 19), (2, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 19), (2, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 19), (2, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24581)$.", + "Output Answer": [ + "$24012$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24581))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35330 \\pmod{98}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(35330 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{16}$\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 17 \\pmod{17}$", + "Output Answer": [ + "$3791$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 16), (18, 11), (17, 3), (17, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 16), (18, 11), (17, 3), (17, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 16), (18, 11), (17, 3), (17, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2382^2067 \\pmod{2685}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(pow(2382, 2067, 2685))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93929 \\pmod{56}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(93929 % 56)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1055x \\equiv 1 \\pmod{2136}$.", + "Output Answer": [ + "$575$" + ], + "Output Program": [ + "print(pow(1055, -1, 2136))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $75438$.", + "Output Answer": [ + "$2^1\\cdot 3^3\\cdot 11^1\\cdot 127^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(75438))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{128,207,58\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 128, 207, 58\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{10}$\n$x \\equiv 12 \\pmod{14}$\n$x \\equiv 8 \\pmod{3}$", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 10), (12, 14), (8, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 10), (12, 14), (8, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1560$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1560 % 6 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{649,167,-730\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 649, 167, -730\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{554}{21}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{21} \\left(\\sqrt{77170}-277\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(554/21)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35915)$.", + "Output Answer": [ + "$26080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35915))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{18}$\n$x \\equiv 15 \\pmod{13}$\n$x \\equiv 7 \\pmod{11}$", + "Output Answer": [ + "$1250$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 18), (15, 13), (7, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 18), (15, 13), (7, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 18), (15, 13), (7, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1337^2187 \\pmod{2288}$.", + "Output Answer": [ + "$1097$" + ], + "Output Program": [ + "print(pow(1337, 2187, 2288))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{431,715\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 431, 715\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-323,458,55\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -323, 458, 55\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=10$ $46$-gonal number.\n", + "Output Answer": [ + "$8326$" + ], + "Output Program": [ + "n = 10\nk = 46\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $5^m \\equiv 1 \\pmod{394}$.", + "Output Answer": [ + "$196$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(5, 394))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-715,55,84\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -715, 55, 84\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{20}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 20), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 20), (6, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 20), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n55531", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55531))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $517^m \\equiv 1 \\pmod{930}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(517, 930))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4269}{2923}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{52400077}-4269}{5846}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4269/2923)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-927$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-927 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10841}{3583}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{168878837}-10841}{7166}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10841/3583)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50977 \\pmod{31}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(50977 % 31)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{411}{1168}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5625817}-411}{2336}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(411/1168)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2856$ is divisible by $-28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2856 % -28 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{654}{2537}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6543298}-327}{2537}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(654/2537)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2539}{3472}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{54665657}-2539}{6944}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2539/3472)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6093)$.", + "Output Answer": [ + "$4056$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6093))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1957}{11757}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{556738045}-1957}{23514}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1957/11757)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $113x \\equiv 1 \\pmod{204}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(pow(113, -1, 204))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $49^m \\equiv 1 \\pmod{453}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(49, 453))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{401,-933\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 401, -933\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $115x \\equiv 1 \\pmod{464}$.", + "Output Answer": [ + "$347$" + ], + "Output Program": [ + "print(pow(115, -1, 464))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $765x \\equiv 1 \\pmod{1136}$.", + "Output Answer": [ + "$741$" + ], + "Output Program": [ + "print(pow(765, -1, 1136))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{21795}{29842}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4037201881}-21795}{59684}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21795/29842)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n6831", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6831))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $95310$.", + "Output Answer": [ + "$2^1\\cdot 3^3\\cdot 5^1\\cdot 353^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(95310))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{8}$\n$x \\equiv 15 \\pmod{5}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 8), (15, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 8), (15, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 8), (15, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-342,509\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -342, 509\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75743 \\pmod{5}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(75743 % 5)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47235 \\pmod{51}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(47235 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9785}{10327}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{522333941}-9785}{20654}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9785/10327)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $23x \\equiv 1 \\pmod{1098}$.", + "Output Answer": [ + "$191$" + ], + "Output Program": [ + "print(pow(23, -1, 1098))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $607^m \\equiv 1 \\pmod{722}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(607, 722))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-813,-741,295\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -813, -741, 295\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $646$ to base $34$.", + "Output Answer": [ + "$\\text{j0}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 646\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $688$ is divisible by $4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(688 % 4 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-548,-578\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -548, -578\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2243)$.", + "Output Answer": [ + "$2242$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2243))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $24709$.", + "Output Answer": [ + "$24709^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(24709))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1763x \\equiv 1 \\pmod{2103}$.", + "Output Answer": [ + "$167$" + ], + "Output Program": [ + "print(pow(1763, -1, 2103))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1262x \\equiv 1 \\pmod{2257}$.", + "Output Answer": [ + "$1175$" + ], + "Output Program": [ + "print(pow(1262, -1, 2257))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1283x \\equiv 1 \\pmod{1555}$.", + "Output Answer": [ + "$1252$" + ], + "Output Program": [ + "print(pow(1283, -1, 1555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45610 \\pmod{12}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(45610 % 12)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8617}{12660}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{715355089}-8617}{25320}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8617/12660)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1255x \\equiv 1 \\pmod{2134}$.", + "Output Answer": [ + "$1277$" + ], + "Output Program": [ + "print(pow(1255, -1, 2134))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n9923", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9923))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-14337$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-14337 % -27 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1907$ to base $3$.", + "Output Answer": [ + "$2121122_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1907\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $314x \\equiv 1 \\pmod{497}$.", + "Output Answer": [ + "$258$" + ], + "Output Program": [ + "print(pow(314, -1, 497))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $453^m \\equiv 1 \\pmod{664}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(453, 664))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 45320 \\pmod{13}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(45320 % 13)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $103^m \\equiv 1 \\pmod{668}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(103, 668))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $182^m \\equiv 1 \\pmod{187}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(182, 187))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $12580$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(12580 % -17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $142^m \\equiv 1 \\pmod{367}$.", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(142, 367))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37682)$.", + "Output Answer": [ + "$18532$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37682))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 4 \\pmod{7}$", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "constraints = (7, 8), (4, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 8), (4, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 8), (4, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27373 \\pmod{81}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "print(27373 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{909,-707,569\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 909, -707, 569\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $342^m \\equiv 1 \\pmod{491}$.", + "Output Answer": [ + "$245$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(342, 491))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $6151$.", + "Output Answer": [ + "$\\{3,6,13,15,21,24,26,29,30,33\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(6151):\n if len(roots) == 10: break\n if gcd(a, 6151) == 1 and is_primitive_root(a, 6151):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76420 \\pmod{90}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(76420 % 90)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $736x \\equiv 1 \\pmod{1327}$.", + "Output Answer": [ + "$723$" + ], + "Output Program": [ + "print(pow(736, -1, 1327))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1708$ is divisible by $28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1708 % 28 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1510^774 \\pmod{2324}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "print(pow(1510, 774, 2324))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-987,125,318\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -987, 125, 318\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $773x \\equiv 1 \\pmod{2294}$.", + "Output Answer": [ + "$1193$" + ], + "Output Program": [ + "print(pow(773, -1, 2294))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1111x \\equiv 1 \\pmod{1767}$.", + "Output Answer": [ + "$967$" + ], + "Output Program": [ + "print(pow(1111, -1, 1767))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.29$ to base $8$.", + "Output Answer": [ + "$0.2243656_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.29\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1679^1234 \\pmod{2681}$.", + "Output Answer": [ + "$1604$" + ], + "Output Program": [ + "print(pow(1679, 1234, 2681))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{780,901\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 780, 901\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2143^958 \\pmod{2284}$.", + "Output Answer": [ + "$2217$" + ], + "Output Program": [ + "print(pow(2143, 958, 2284))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $178x \\equiv 1 \\pmod{361}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "print(pow(178, -1, 361))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1208^1420 \\pmod{1650}$.", + "Output Answer": [ + "$826$" + ], + "Output Program": [ + "print(pow(1208, 1420, 1650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{77,340,61\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 77, 340, 61\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1165^1525 \\pmod{1722}$.", + "Output Answer": [ + "$1585$" + ], + "Output Program": [ + "print(pow(1165, 1525, 1722))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73544 \\pmod{70}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(73544 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-102$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-102 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24773 \\pmod{86}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(24773 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2501$ to base $16$.", + "Output Answer": [ + "$\\text{9c5}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2501\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{15}$\n$x \\equiv 12 \\pmod{11}$", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 15), (12, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 15), (12, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 15), (12, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32321)$.", + "Output Answer": [ + "$32320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32321))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $139^m \\equiv 1 \\pmod{500}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(139, 500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 11 \\pmod{6}$", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 17), (15, 10), (11, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 17), (15, 10), (11, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1184x \\equiv 1 \\pmod{1479}$.", + "Output Answer": [ + "$371$" + ], + "Output Program": [ + "print(pow(1184, -1, 1479))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47804 \\pmod{71}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(47804 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $964x \\equiv 1 \\pmod{1795}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(pow(964, -1, 1795))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-668,-40\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -668, -40\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1548}{7567}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{57858565}-774}{7567}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1548/7567)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $120^2401 \\pmod{2452}$.", + "Output Answer": [ + "$1200$" + ], + "Output Program": [ + "print(pow(120, 2401, 2452))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{32059}{32295}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5199647581}-32059}{64590}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(32059/32295)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $3850_9$ to base 10.", + "Output Answer": [ + "$2880$" + ], + "Output Program": [ + "n = '3850'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47312 \\pmod{18}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(47312 % 18)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $699$ to base $26$.", + "Output Answer": [ + "$\\text{10n}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 699\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $45$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(45 % -18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1452$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1452 % -11 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34692 \\pmod{11}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(34692 % 11)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4843}{1556}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{33139193}-4843}{3112}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4843/1556)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5633)$.", + "Output Answer": [ + "$5460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5633))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5628}{1705}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10825621}-2814}{1705}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5628/1705)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85473 \\pmod{71}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(85473 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7633}{8564}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{351631073}-7633}{17128}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7633/8564)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $24725$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(24725 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{151}{5842}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{136538657}-151}{11684}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(151/5842)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $826_{17}$ to base 10.", + "Output Answer": [ + "$2352$" + ], + "Output Program": [ + "n = '826'.strip('.')\nbase = 17\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-95,-24\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -95, -24\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 20 \\pmod{4}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (20, 5), (17, 17), (20, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 5), (20, 5), (17, 17), (20, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $221x \\equiv 1 \\pmod{1138}$.", + "Output Answer": [ + "$793$" + ], + "Output Program": [ + "print(pow(221, -1, 1138))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{218,922\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 218, 922\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{14}$\n$x \\equiv 19 \\pmod{3}$\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 17 \\pmod{8}$", + "Output Answer": [ + "$433$" + ], + "Output Program": [ + "constraints = (13, 14), (19, 3), (4, 11), (17, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 14), (19, 3), (4, 11), (17, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{19945}{15571}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1367627189}-19945}{31142}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19945/15571)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.53251403_6$ to base 10.", + "Output Answer": [ + "$0.93$" + ], + "Output Program": [ + "n = '0.53251403'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1836^1391 \\pmod{1921}$.", + "Output Answer": [ + "$1598$" + ], + "Output Program": [ + "print(pow(1836, 1391, 1921))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33369)$.", + "Output Answer": [ + "$18984$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6471}{16790}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1169490241}-6471}{33580}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6471/16790)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $11689$.", + "Output Answer": [ + "$\\{7,11,17,26,28,29,35,39,42,44\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(11689):\n if len(roots) == 10: break\n if gcd(a, 11689) == 1 and is_primitive_root(a, 11689):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97305", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97305))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $401$ to base $31$.", + "Output Answer": [ + "$\\text{ct}_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 401\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $18500$ is divisible by $-20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18500 % -20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53297 \\pmod{91}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(53297 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8948}{35669}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1292294237}-4474}{35669}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8948/35669)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10191}{20486}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1782561265}-10191}{40972}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10191/20486)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96307 \\pmod{91}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(96307 % 91)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $378^2379 \\pmod{1939}$.", + "Output Answer": [ + "$1169$" + ], + "Output Program": [ + "print(pow(378, 2379, 1939))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $74^m \\equiv 1 \\pmod{117}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(74, 117))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1682}{1539}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3075802}-841}{1539}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1682/1539)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{19}$\n$x \\equiv 0 \\pmod{4}$", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 19), (0, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 19), (0, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 19), (0, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2370^1833 \\pmod{2821}$.", + "Output Answer": [ + "$2248$" + ], + "Output Program": [ + "print(pow(2370, 1833, 2821))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28226)$.", + "Output Answer": [ + "$12820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28226))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $279^2058 \\pmod{1064}$.", + "Output Answer": [ + "$505$" + ], + "Output Program": [ + "print(pow(279, 2058, 1064))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-770$ is divisible by $7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-770 % 7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-5,1,-2,-1\\}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "import math\n\nvalues = -5, 1, -2, -1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{655,246\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 655, 246\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{18577}{8753}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{651564965}-18577}{17506}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18577/8753)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1254$ to base $33$.", + "Output Answer": [ + "$150_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1254\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7961}{23651}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{92034269}-7961}{47302}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7961/23651)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{289,-781,-179\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 289, -781, -179\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{20667}{15836}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1430240473}-20667}{31672}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20667/15836)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8627 \\pmod{86}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(8627 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $11^m \\equiv 1 \\pmod{512}$.", + "Output Answer": [ + "$128$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(11, 512))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n9325", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9325))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1514$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1514 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{502,255,622\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 502, 255, 622\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36314)$.", + "Output Answer": [ + "$17820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36314))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $19031$.", + "Output Answer": [ + "$\\{11,22,31,33,37,41,44,55,62,66\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(19031):\n if len(roots) == 10: break\n if gcd(a, 19031) == 1 and is_primitive_root(a, 19031):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $703^784 \\pmod{1719}$.", + "Output Answer": [ + "$1396$" + ], + "Output Program": [ + "print(pow(703, 784, 1719))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $65x \\equiv 1 \\pmod{1178}$.", + "Output Answer": [ + "$145$" + ], + "Output Program": [ + "print(pow(65, -1, 1178))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $887^m \\equiv 1 \\pmod{918}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(887, 918))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6840}{4201}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{29344801}-3420}{4201}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6840/4201)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2262$ to base $12$.", + "Output Answer": [ + "$1386_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2262\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57416 \\pmod{64}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(57416 % 64)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2835$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2835 % 49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-485,174,73\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -485, 174, 73\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $61118$.", + "Output Answer": [ + "$\\{7,15,35,39,41,53,55,61,63,71\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(61118):\n if len(roots) == 10: break\n if gcd(a, 61118) == 1 and is_primitive_root(a, 61118):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2032^1307 \\pmod{2096}$.", + "Output Answer": [ + "$1760$" + ], + "Output Program": [ + "print(pow(2032, 1307, 2096))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $671^1379 \\pmod{2971}$.", + "Output Answer": [ + "$847$" + ], + "Output Program": [ + "print(pow(671, 1379, 2971))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $12332_4$ to base 10.", + "Output Answer": [ + "$446$" + ], + "Output Program": [ + "n = '12332'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47859)$.", + "Output Answer": [ + "$26208$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-223,41\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -223, 41\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $815^1281 \\pmod{1166}$.", + "Output Answer": [ + "$1145$" + ], + "Output Program": [ + "print(pow(815, 1281, 1166))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1470$ to base $25$.", + "Output Answer": [ + "$\\text{28k}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1470\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $88x \\equiv 1 \\pmod{111}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "print(pow(88, -1, 111))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9170 \\pmod{32}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(9170 % 32)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{579}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 579))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8428 \\pmod{75}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(8428 % 75)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38643)$.", + "Output Answer": [ + "$23400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38643))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-746,759\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -746, 759\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-856,-67\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -856, -67\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.55$ to base $22$.", + "Output Answer": [ + "$\\text{0.c249}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.55\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10}{31}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{31} \\left(\\sqrt{986}-5\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10/31)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $86927$.", + "Output Answer": [ + "$86927^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(86927))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $745^m \\equiv 1 \\pmod{751}$.", + "Output Answer": [ + "$125$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(745, 751))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{15}$\n$x \\equiv 8 \\pmod{2}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 15), (8, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 15), (8, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 15), (8, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n10135", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10135))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20385)$.", + "Output Answer": [ + "$10800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20385))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-411$ is divisible by $-47$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-411 % -47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $3366$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3366 % -18 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44118)$.", + "Output Answer": [ + "$13608$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44118))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-919,881\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -919, 881\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54000 \\pmod{46}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(54000 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $448^m \\equiv 1 \\pmod{515}$.", + "Output Answer": [ + "$204$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(448, 515))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1995^1084 \\pmod{2366}$.", + "Output Answer": [ + "$1491$" + ], + "Output Program": [ + "print(pow(1995, 1084, 2366))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1459^1835 \\pmod{1659}$.", + "Output Answer": [ + "$922$" + ], + "Output Program": [ + "print(pow(1459, 1835, 1659))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 19 \\pmod{5}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 3), (19, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 3), (19, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 3), (19, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $493x \\equiv 1 \\pmod{1272}$.", + "Output Answer": [ + "$805$" + ], + "Output Program": [ + "print(pow(493, -1, 1272))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{340,307\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 340, 307\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $296^2343 \\pmod{567}$.", + "Output Answer": [ + "$323$" + ], + "Output Program": [ + "print(pow(296, 2343, 567))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $60343$.", + "Output Answer": [ + "$\\{3,5,6,10,12,17,20,21,24,33\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(60343):\n if len(roots) == 10: break\n if gcd(a, 60343) == 1 and is_primitive_root(a, 60343):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16074}{23405}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{612387394}-8037}{23405}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16074/23405)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $32$ is divisible by $23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(32 % 23 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $809^1419 \\pmod{1345}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(809, 1419, 1345))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{13}$\n$x \\equiv 16 \\pmod{7}$\n$x \\equiv 10 \\pmod{4}$\n$x \\equiv 14 \\pmod{10}$", + "Output Answer": [ + "$814$" + ], + "Output Program": [ + "constraints = (8, 13), (16, 7), (10, 4), (14, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 13), (16, 7), (10, 4), (14, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1735$ to base $31$.", + "Output Answer": [ + "$\\text{1ou}_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1735\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $89$ to base $36$.", + "Output Answer": [ + "$\\text{2h}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 89\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $863$ to base $7$.", + "Output Answer": [ + "$2342_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 863\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38457 \\pmod{10}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(38457 % 10)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2351^181 \\pmod{2391}$.", + "Output Answer": [ + "$743$" + ], + "Output Program": [ + "print(pow(2351, 181, 2391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 1 \\pmod{16}$", + "Output Answer": [ + "$385$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 7), (15, 5), (11, 11), (1, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (15, 5), (11, 11), (1, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 7), (15, 5), (11, 11), (1, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $159^m \\equiv 1 \\pmod{259}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(159, 259))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n71291", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71291))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10877}{15116}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1032282953}-10877}{30232}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10877/15116)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $18947$.", + "Output Answer": [ + "$\\{2,5,6,8,11,13,14,15,18,19\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(18947):\n if len(roots) == 10: break\n if gcd(a, 18947) == 1 and is_primitive_root(a, 18947):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34876)$.", + "Output Answer": [ + "$17436$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34876))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{15}$\n$x \\equiv 15 \\pmod{16}$", + "Output Answer": [ + "$191$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 15), (15, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 15), (15, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 15), (15, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{13}$\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 2 \\pmod{20}$", + "Output Answer": [ + "$182$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 13), (10, 2), (2, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 13), (10, 2), (2, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 28531 \\pmod{20}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(28531 % 20)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46352)$.", + "Output Answer": [ + "$23168$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46352))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{16909}{16982}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1439467577}-16909}{33964}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16909/16982)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49468 \\pmod{46}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(49468 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $583^m \\equiv 1 \\pmod{964}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(583, 964))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25891)$.", + "Output Answer": [ + "$24352$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25891))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $22^m \\equiv 1 \\pmod{93}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(22, 93))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1140^384 \\pmod{1650}$.", + "Output Answer": [ + "$300$" + ], + "Output Program": [ + "print(pow(1140, 384, 1650))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96406 \\pmod{69}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(96406 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $781x \\equiv 1 \\pmod{2040}$.", + "Output Answer": [ + "$781$" + ], + "Output Program": [ + "print(pow(781, -1, 2040))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $141x \\equiv 1 \\pmod{1378}$.", + "Output Answer": [ + "$1163$" + ], + "Output Program": [ + "print(pow(141, -1, 1378))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{402}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 402))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,2,1\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 2, 1\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6629)$.", + "Output Answer": [ + "$5676$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6629))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-188$ is divisible by $-2$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-188 % -2 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $391x \\equiv 1 \\pmod{825}$.", + "Output Answer": [ + "$211$" + ], + "Output Program": [ + "print(pow(391, -1, 825))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $489^m \\equiv 1 \\pmod{664}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(489, 664))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $157x \\equiv 1 \\pmod{415}$.", + "Output Answer": [ + "$378$" + ], + "Output Program": [ + "print(pow(157, -1, 415))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36713)$.", + "Output Answer": [ + "$36712$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36713))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $11x \\equiv 1 \\pmod{2174}$.", + "Output Answer": [ + "$593$" + ], + "Output Program": [ + "print(pow(11, -1, 2174))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34174 \\pmod{25}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(34174 % 25)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $348^658 \\pmod{2667}$.", + "Output Answer": [ + "$996$" + ], + "Output Program": [ + "print(pow(348, 658, 2667))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11236 \\pmod{55}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(11236 % 55)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42826)$.", + "Output Answer": [ + "$16632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42826))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1498$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1498 % 14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $775x \\equiv 1 \\pmod{2372}$.", + "Output Answer": [ + "$2271$" + ], + "Output Program": [ + "print(pow(775, -1, 2372))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-258,329\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -258, 329\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1134^1379 \\pmod{2824}$.", + "Output Answer": [ + "$1768$" + ], + "Output Program": [ + "print(pow(1134, 1379, 2824))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $401x \\equiv 1 \\pmod{490}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(401, -1, 490))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11378 \\pmod{66}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(11378 % 66)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5945}{172}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{344} \\left(\\sqrt{35461361}-5945\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5945/172)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{295}{62}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{124} \\left(\\sqrt{102401}-295\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(295/62)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $657x \\equiv 1 \\pmod{835}$.", + "Output Answer": [ + "$258$" + ], + "Output Program": [ + "print(pow(657, -1, 835))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{838,-440\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 838, -440\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $41700$.", + "Output Answer": [ + "$2^2\\cdot 3^1\\cdot 5^2\\cdot 139^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(41700))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4330}{723}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{723} \\left(\\sqrt{5209954}-2165\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4330/723)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{72,93,232\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 72, 93, 232\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-440,-331,369\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -440, -331, 369\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31596)$.", + "Output Answer": [ + "$10528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31596))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(374)$.", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(374))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $33^m \\equiv 1 \\pmod{98}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(33, 98))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2054^916 \\pmod{2648}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "print(pow(2054, 916, 2648))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $8^m \\equiv 1 \\pmod{65}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(8, 65))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4225}{4704}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{106361089}-4225}{9408}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4225/4704)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 2 \\pmod{19}$\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 19 \\pmod{6}$", + "Output Answer": [ + "$1237$" + ], + "Output Program": [ + "constraints = (4, 3), (2, 19), (16, 11), (19, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 3), (2, 19), (16, 11), (19, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-969,925\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -969, 925\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-495,191\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -495, 191\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $25073$.", + "Output Answer": [ + "$\\{3,5,6,7,10,12,14,19,20,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(25073):\n if len(roots) == 10: break\n if gcd(a, 25073) == 1 and is_primitive_root(a, 25073):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $191x \\equiv 1 \\pmod{438}$.", + "Output Answer": [ + "$305$" + ], + "Output Program": [ + "print(pow(191, -1, 438))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $413x \\equiv 1 \\pmod{538}$.", + "Output Answer": [ + "$439$" + ], + "Output Program": [ + "print(pow(413, -1, 538))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1077x \\equiv 1 \\pmod{1742}$.", + "Output Answer": [ + "$1501$" + ], + "Output Program": [ + "print(pow(1077, -1, 1742))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{838,-625\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 838, -625\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{19}$\n$x \\equiv 10 \\pmod{6}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "constraints = (4, 19), (10, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 19), (10, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 19), (10, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $93^1110 \\pmod{297}$.", + "Output Answer": [ + "$243$" + ], + "Output Program": [ + "print(pow(93, 1110, 297))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n34481", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(34481))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $59873$.", + "Output Answer": [ + "$11^1\\cdot 5443^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(59873))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $28971$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(28971 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $371^m \\equiv 1 \\pmod{942}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(371, 942))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $83112$.", + "Output Answer": [ + "$2^3\\cdot 3^1\\cdot 3463^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(83112))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25125 \\pmod{16}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(25125 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1075^2076 \\pmod{2078}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(1075, 2076, 2078))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $329x \\equiv 1 \\pmod{972}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(pow(329, -1, 972))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2045}{12294}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{608751769}-2045}{24588}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2045/12294)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{19}$\n$x \\equiv 6 \\pmod{17}$", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "constraints = (20, 19), (6, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 19), (6, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (20, 19), (6, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11187)$.", + "Output Answer": [ + "$6720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11187))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-14870$ is divisible by $40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-14870 % 40 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41387$.", + "Output Answer": [ + "$\\{2,5,6,8,11,13,14,15,18,19\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41387):\n if len(roots) == 10: break\n if gcd(a, 41387) == 1 and is_primitive_root(a, 41387):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16758)$.", + "Output Answer": [ + "$4536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16758))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-830,56\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -830, 56\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31833)$.", + "Output Answer": [ + "$21060$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31833))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $310^1688 \\pmod{1509}$.", + "Output Answer": [ + "$736$" + ], + "Output Program": [ + "print(pow(310, 1688, 1509))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $602$ to base $26$.", + "Output Answer": [ + "$\\text{n4}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 602\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8349}{5036}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{171150985}-8349}{10072}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8349/5036)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-26,-789\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -26, -789\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $113x \\equiv 1 \\pmod{1736}$.", + "Output Answer": [ + "$169$" + ], + "Output Program": [ + "print(pow(113, -1, 1736))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17941}{21944}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{89921441}-17941}{43888}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17941/21944)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{5}$\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 7 \\pmod{16}$", + "Output Answer": [ + "$407$" + ], + "Output Program": [ + "constraints = (7, 5), (1, 7), (7, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 5), (1, 7), (7, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 5), (1, 7), (7, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{7}$\n$x \\equiv 12 \\pmod{20}$\n$x \\equiv 16 \\pmod{4}$", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 7), (12, 20), (16, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 7), (12, 20), (16, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $31$ is divisible by $-1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(31 % -1 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23770)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{3}$\n$x \\equiv 15 \\pmod{7}$\n$x \\equiv 4 \\pmod{20}$", + "Output Answer": [ + "$344$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 3), (15, 7), (4, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 3), (15, 7), (4, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 3), (15, 7), (4, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27468 \\pmod{16}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(27468 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97421", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97421))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25932)$.", + "Output Answer": [ + "$8640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25932))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-183,-486,158\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -183, -486, 158\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $8505$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8505 % 15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n44085", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44085))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $497x \\equiv 1 \\pmod{1677}$.", + "Output Answer": [ + "$1127$" + ], + "Output Program": [ + "print(pow(497, -1, 1677))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $140^m \\equiv 1 \\pmod{141}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(140, 141))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-22875$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-22875 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1167$ is divisible by $43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1167 % 43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n89071", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89071))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{226}$.", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "print(pow(79, -1, 226))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1480x \\equiv 1 \\pmod{1791}$.", + "Output Answer": [ + "$979$" + ], + "Output Program": [ + "print(pow(1480, -1, 1791))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1728^2427 \\pmod{1855}$.", + "Output Answer": [ + "$1602$" + ], + "Output Program": [ + "print(pow(1728, 2427, 1855))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{396,149,322\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 396, 149, 322\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1734^1778 \\pmod{2809}$.", + "Output Answer": [ + "$134$" + ], + "Output Program": [ + "print(pow(1734, 1778, 2809))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-603,80,19\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -603, 80, 19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 0 \\pmod{19}$", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "constraints = (4, 17), (0, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 17), (0, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 17), (0, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $325x \\equiv 1 \\pmod{894}$.", + "Output Answer": [ + "$883$" + ], + "Output Program": [ + "print(pow(325, -1, 894))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $173^m \\equiv 1 \\pmod{293}$.", + "Output Answer": [ + "$292$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(173, 293))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{26908}{9161}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{264934037}-13454}{9161}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26908/9161)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{121,480\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 121, 480\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $74^m \\equiv 1 \\pmod{257}$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(74, 257))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $19x \\equiv 1 \\pmod{326}$.", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "print(pow(19, -1, 326))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $10550$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(10550 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27227)$.", + "Output Answer": [ + "$25776$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=12$ $17$-gonal number.\n", + "Output Answer": [ + "$1377$" + ], + "Output Program": [ + "n = 12\nk = 17\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $5437$.", + "Output Answer": [ + "$\\{5,6,7,17,18,19,20,22,24,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(5437):\n if len(roots) == 10: break\n if gcd(a, 5437) == 1 and is_primitive_root(a, 5437):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $337x \\equiv 1 \\pmod{546}$.", + "Output Answer": [ + "$337$" + ], + "Output Program": [ + "print(pow(337, -1, 546))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{814,-659,43\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 814, -659, 43\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4801}{53}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{106} \\left(\\sqrt{23060837}-4801\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4801/53)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{43,-359,919\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 43, -359, 919\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17221)$.", + "Output Answer": [ + "$16192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17221))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{584}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 584))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47531 \\pmod{86}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(47531 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16457)$.", + "Output Answer": [ + "$14100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16457))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $793^m \\equiv 1 \\pmod{816}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(793, 816))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $29x \\equiv 1 \\pmod{600}$.", + "Output Answer": [ + "$269$" + ], + "Output Program": [ + "print(pow(29, -1, 600))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-270$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-270 % 5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47914)$.", + "Output Answer": [ + "$23956$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47914))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $141$ to base $36$.", + "Output Answer": [ + "$\\text{3x}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 141\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{962,589,-789\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 962, 589, -789\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-29$ is divisible by $-2$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-29 % -2 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $12x \\equiv 1 \\pmod{43}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(pow(12, -1, 43))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1192$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1192 % -42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $213$ to base $13$.", + "Output Answer": [ + "$135_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 213\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $256^m \\equiv 1 \\pmod{385}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(256, 385))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{571}{750}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2576041}-571}{1500}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(571/750)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48974)$.", + "Output Answer": [ + "$23920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48974))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $346x \\equiv 1 \\pmod{753}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(pow(346, -1, 753))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38705)$.", + "Output Answer": [ + "$30960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38705))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $598^422 \\pmod{755}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(pow(598, 422, 755))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-279,-913\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -279, -913\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30456 \\pmod{88}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(30456 % 88)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $97x \\equiv 1 \\pmod{2433}$.", + "Output Answer": [ + "$301$" + ], + "Output Program": [ + "print(pow(97, -1, 2433))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $759^m \\equiv 1 \\pmod{992}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(759, 992))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $686^m \\equiv 1 \\pmod{859}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(686, 859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67468 \\pmod{8}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(67468 % 8)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n95021", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(95021))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $369x \\equiv 1 \\pmod{1090}$.", + "Output Answer": [ + "$449$" + ], + "Output Program": [ + "print(pow(369, -1, 1090))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $183^m \\equiv 1 \\pmod{895}$.", + "Output Answer": [ + "$356$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(183, 895))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1040$ to base $19$.", + "Output Answer": [ + "$\\text{2ge}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1040\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n101357", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49031 \\pmod{87}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(49031 % 87)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{14}$\n$x \\equiv 16 \\pmod{15}$\n$x \\equiv 1 \\pmod{3}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "constraints = (3, 14), (16, 15), (1, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 14), (16, 15), (1, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10033 \\pmod{20}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(10033 % 20)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-49797$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-49797 % 33 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1468x \\equiv 1 \\pmod{1971}$.", + "Output Answer": [ + "$721$" + ], + "Output Program": [ + "print(pow(1468, -1, 1971))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $365x \\equiv 1 \\pmod{1718}$.", + "Output Answer": [ + "$273$" + ], + "Output Program": [ + "print(pow(365, -1, 1718))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $10650$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(10650 % 15 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2180^2292 \\pmod{2296}$.", + "Output Answer": [ + "$400$" + ], + "Output Program": [ + "print(pow(2180, 2292, 2296))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $209^m \\equiv 1 \\pmod{364}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(209, 364))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{5}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "constraints = (12, 5), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 5), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 5), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8908}{12353}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{6897389}-4454}{12353}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8908/12353)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43433)$.", + "Output Answer": [ + "$39936$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43433))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91135 \\pmod{100}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(91135 % 100)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $815^m \\equiv 1 \\pmod{928}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(815, 928))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69589 \\pmod{27}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(69589 % 27)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25935)$.", + "Output Answer": [ + "$10368$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25935))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $448$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(448 % -14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{5}$\n$x \\equiv 15 \\pmod{12}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "constraints = (0, 5), (15, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 5), (15, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 5), (15, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1049^363 \\pmod{2849}$.", + "Output Answer": [ + "$2715$" + ], + "Output Program": [ + "print(pow(1049, 363, 2849))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5238)$.", + "Output Answer": [ + "$1728$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5238))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $14998$.", + "Output Answer": [ + "$\\{7,21,23,29,31,35,39,43,53,63\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(14998):\n if len(roots) == 10: break\n if gcd(a, 14998) == 1 and is_primitive_root(a, 14998):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46237 \\pmod{14}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(46237 % 14)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1224x \\equiv 1 \\pmod{2281}$.", + "Output Answer": [ + "$1161$" + ], + "Output Program": [ + "print(pow(1224, -1, 2281))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n99705", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(99705))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1768$ to base $33$.", + "Output Answer": [ + "$\\text{1kj}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1768\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $550^m \\equiv 1 \\pmod{793}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(550, 793))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $753^m \\equiv 1 \\pmod{965}$.", + "Output Answer": [ + "$192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(753, 965))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $84610$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 8461^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(84610))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-600,383\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -600, 383\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56128 \\pmod{46}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(56128 % 46)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1991^1269 \\pmod{2619}$.", + "Output Answer": [ + "$2294$" + ], + "Output Program": [ + "print(pow(1991, 1269, 2619))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22339 \\pmod{25}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(22339 % 25)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57292 \\pmod{97}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(57292 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8733}{11699}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{623731693}-8733}{23398}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8733/11699)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61972 \\pmod{61}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(61972 % 61)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1075$ to base $33$.", + "Output Answer": [ + "$\\text{wj}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1075\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $135^m \\equiv 1 \\pmod{332}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(135, 332))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $9360$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9360 % 20 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n19533", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(19533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-13536$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-13536 % 24 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n2649", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2649))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-269,-402,-931\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -269, -402, -931\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73067 \\pmod{97}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(73067 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41838 \\pmod{24}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(41838 % 24)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.848$ to base $2$.", + "Output Answer": [ + "$0.11011001000101101_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.848\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1394x \\equiv 1 \\pmod{1485}$.", + "Output Answer": [ + "$359$" + ], + "Output Program": [ + "print(pow(1394, -1, 1485))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-292,796\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -292, 796\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(853)$.", + "Output Answer": [ + "$852$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(853))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32728)$.", + "Output Answer": [ + "$16360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32728))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{977,-30\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 977, -30\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $487^m \\equiv 1 \\pmod{991}$.", + "Output Answer": [ + "$495$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(487, 991))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44983)$.", + "Output Answer": [ + "$44982$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44983))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6318 \\pmod{72}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(6318 % 72)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.$ to base $6$.", + "Output Answer": [ + "$0._6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $703^m \\equiv 1 \\pmod{865}$.", + "Output Answer": [ + "$172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(703, 865))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1040^747 \\pmod{1904}$.", + "Output Answer": [ + "$1520$" + ], + "Output Program": [ + "print(pow(1040, 747, 1904))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1126$ is divisible by $16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1126 % 16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12354 \\pmod{16}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(12354 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n97553", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97553))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2032^1828 \\pmod{2450}$.", + "Output Answer": [ + "$2326$" + ], + "Output Program": [ + "print(pow(2032, 1828, 2450))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $733x \\equiv 1 \\pmod{2007}$.", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "print(pow(733, -1, 2007))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{11}$\n$x \\equiv 13 \\pmod{6}$", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "constraints = (10, 11), (13, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 11), (13, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 11), (13, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1384^544 \\pmod{1507}$.", + "Output Answer": [ + "$412$" + ], + "Output Program": [ + "print(pow(1384, 544, 1507))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{499,152\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 499, 152\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $307x \\equiv 1 \\pmod{882}$.", + "Output Answer": [ + "$181$" + ], + "Output Program": [ + "print(pow(307, -1, 882))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2759)$.", + "Output Answer": [ + "$2640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2759))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{3}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (0, 3), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (0, 3), (14, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 3), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1272^2307 \\pmod{2141}$.", + "Output Answer": [ + "$1691$" + ], + "Output Program": [ + "print(pow(1272, 2307, 2141))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $76$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(76 % -22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $65x \\equiv 1 \\pmod{369}$.", + "Output Answer": [ + "$176$" + ], + "Output Program": [ + "print(pow(65, -1, 369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 20 \\pmod{17}$\n$x \\equiv 0 \\pmod{11}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$13926$" + ], + "Output Program": [ + "import math\n\nconstraints = (16, 10), (20, 17), (0, 11), (16, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 10), (20, 17), (0, 11), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 10), (20, 17), (0, 11), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $73876$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(73876 % -46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $255^1287 \\pmod{1377}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(255, 1287, 1377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12877 \\pmod{51}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(12877 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-980,691,951\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -980, 691, 951\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52410 \\pmod{76}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(52410 % 76)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{5,306\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 5, 306\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3289}{1054}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{15261185}-3289}{2108}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3289/1054)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3061}{8559}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{302395645}-3061}{17118}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3061/8559)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $640^2210 \\pmod{1674}$.", + "Output Answer": [ + "$118$" + ], + "Output Program": [ + "print(pow(640, 2210, 1674))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1599$ is divisible by $34$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1599 % 34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{31046}{38235}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1702878754}-15523}{38235}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31046/38235)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2464^704 \\pmod{2719}$.", + "Output Answer": [ + "$2653$" + ], + "Output Program": [ + "print(pow(2464, 704, 2719))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $81959$.", + "Output Answer": [ + "$41^1\\cdot 1999^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(81959))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46996)$.", + "Output Answer": [ + "$22680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46996))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28578)$.", + "Output Answer": [ + "$8640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28578))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $24x \\equiv 1 \\pmod{89}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(pow(24, -1, 89))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $889$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(889 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12598}{11365}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{168840626}-6299}{11365}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12598/11365)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1460x \\equiv 1 \\pmod{1999}$.", + "Output Answer": [ + "$1617$" + ], + "Output Program": [ + "print(pow(1460, -1, 1999))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46600)$.", + "Output Answer": [ + "$18560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46600))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{14}$\n$x \\equiv 10 \\pmod{19}$", + "Output Answer": [ + "$143$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 14), (10, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 14), (10, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 14), (10, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86632 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(86632 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1013$ to base $17$.", + "Output Answer": [ + "$\\text{38a}_{17}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 17\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1013\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $211x \\equiv 1 \\pmod{798}$.", + "Output Answer": [ + "$295$" + ], + "Output Program": [ + "print(pow(211, -1, 798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2474}{379}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{379} \\left(\\sqrt{1673810}-1237\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2474/379)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $797x \\equiv 1 \\pmod{1954}$.", + "Output Answer": [ + "$939$" + ], + "Output Program": [ + "print(pow(797, -1, 1954))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27406)$.", + "Output Answer": [ + "$13440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27406))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $45442$.", + "Output Answer": [ + "$\\{3,7,11,15,23,27,31,35,39,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(45442):\n if len(roots) == 10: break\n if gcd(a, 45442) == 1 and is_primitive_root(a, 45442):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-60,565,359\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -60, 565, 359\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $219$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(219 % -7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68724 \\pmod{32}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(68724 % 32)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $10530$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(10530 % 26 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $678^360 \\pmod{1270}$.", + "Output Answer": [ + "$286$" + ], + "Output Program": [ + "print(pow(678, 360, 1270))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1887x \\equiv 1 \\pmod{2161}$.", + "Output Answer": [ + "$418$" + ], + "Output Program": [ + "print(pow(1887, -1, 2161))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{223,858,-530\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 223, 858, -530\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1480^478 \\pmod{2903}$.", + "Output Answer": [ + "$2009$" + ], + "Output Program": [ + "print(pow(1480, 478, 2903))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $247x \\equiv 1 \\pmod{326}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(pow(247, -1, 326))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{5,3,2\\}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "import math\n\nvalues = 5, 3, 2\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $419^m \\equiv 1 \\pmod{960}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(419, 960))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $215^m \\equiv 1 \\pmod{246}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(215, 246))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2088^2001 \\pmod{2216}$.", + "Output Answer": [ + "$1168$" + ], + "Output Program": [ + "print(pow(2088, 2001, 2216))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$172$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 11), (1, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 11), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 11), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{4}$\n$x \\equiv 10 \\pmod{14}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 4), (10, 14), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 4), (10, 14), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-39150$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-39150 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6450 \\pmod{6}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(6450 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $475x \\equiv 1 \\pmod{1179}$.", + "Output Answer": [ + "$139$" + ], + "Output Program": [ + "print(pow(475, -1, 1179))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-945$ is divisible by $34$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-945 % 34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{36893}{9011}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1685885933}-36893}{18022}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36893/9011)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-20,448,4\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -20, 448, 4\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1206$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1206 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2886$ to base $7$.", + "Output Answer": [ + "$11262_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2886\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $347x \\equiv 1 \\pmod{1854}$.", + "Output Answer": [ + "$1667$" + ], + "Output Program": [ + "print(pow(347, -1, 1854))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58291 \\pmod{97}$.", + "Output Answer": [ + "$91$" + ], + "Output Program": [ + "print(58291 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1104x \\equiv 1 \\pmod{2309}$.", + "Output Answer": [ + "$1646$" + ], + "Output Program": [ + "print(pow(1104, -1, 2309))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33394 \\pmod{64}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(33394 % 64)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80043 \\pmod{49}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(80043 % 49)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26391)$.", + "Output Answer": [ + "$16632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26391))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1557^2073 \\pmod{2468}$.", + "Output Answer": [ + "$2229$" + ], + "Output Program": [ + "print(pow(1557, 2073, 2468))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n3731", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(3731))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{462}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6031}{2258}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{56767217}-6031}{4516}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6031/2258)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7806}{21463}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{475893778}-3903}{21463}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7806/21463)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{16}$\n$x \\equiv 16 \\pmod{10}$", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 16), (16, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 16), (16, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $498^1120 \\pmod{1995}$.", + "Output Answer": [ + "$351$" + ], + "Output Program": [ + "print(pow(498, 1120, 1995))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40919 \\pmod{70}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(40919 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n86379", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(86379))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75925 \\pmod{86}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(75925 % 86)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $979^2044 \\pmod{1680}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(979, 2044, 1680))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n60919", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60919))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-285,284\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -285, 284\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{586,-77,515\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 586, -77, 515\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $62^1739 \\pmod{1771}$.", + "Output Answer": [ + "$1350$" + ], + "Output Program": [ + "print(pow(62, 1739, 1771))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2000^2302 \\pmod{2322}$.", + "Output Answer": [ + "$1546$" + ], + "Output Program": [ + "print(pow(2000, 2302, 2322))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 10 \\pmod{14}$\n$x \\equiv 2 \\pmod{17}$", + "Output Answer": [ + "$4252$" + ], + "Output Program": [ + "import math\n\nconstraints = (15, 19), (10, 14), (2, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 19), (10, 14), (2, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 19), (10, 14), (2, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-314$ is divisible by $14$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-314 % 14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1067x \\equiv 1 \\pmod{1266}$.", + "Output Answer": [ + "$299$" + ], + "Output Program": [ + "print(pow(1067, -1, 1266))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55949 \\pmod{82}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(55949 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $99x \\equiv 1 \\pmod{1070}$.", + "Output Answer": [ + "$789$" + ], + "Output Program": [ + "print(pow(99, -1, 1070))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{15}$\n$x \\equiv 10 \\pmod{8}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 15), (10, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 15), (10, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 15), (10, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20701 \\pmod{53}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(20701 % 53)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $547^1002 \\pmod{1721}$.", + "Output Answer": [ + "$1552$" + ], + "Output Program": [ + "print(pow(547, 1002, 1721))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76136 \\pmod{30}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(76136 % 30)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15870)$.", + "Output Answer": [ + "$4048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15870))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $4015_6$ to base 10.", + "Output Answer": [ + "$875$" + ], + "Output Program": [ + "n = '4015'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 12 \\pmod{10}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 3), (12, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 3), (12, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 3), (12, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2054}{1381}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2961890}-1027}{1381}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2054/1381)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-208,843\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -208, 843\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41357 \\pmod{38}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(41357 % 38)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2272^1767 \\pmod{2824}$.", + "Output Answer": [ + "$2144$" + ], + "Output Program": [ + "print(pow(2272, 1767, 2824))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1475$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1475 % -31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-825,755\\}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nvalues = -825, 755\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39911)$.", + "Output Answer": [ + "$39432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39911))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $523x \\equiv 1 \\pmod{592}$.", + "Output Answer": [ + "$163$" + ], + "Output Program": [ + "print(pow(523, -1, 592))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.13$ to base $25$.", + "Output Answer": [ + "$0.3666_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.13\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $425x \\equiv 1 \\pmod{2456}$.", + "Output Answer": [ + "$601$" + ], + "Output Program": [ + "print(pow(425, -1, 2456))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{79}{1113}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4961317}-79}{2226}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(79/1113)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $181^m \\equiv 1 \\pmod{500}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(181, 500))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 13 \\pmod{5}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "import math\n\nconstraints = (16, 2), (13, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 2), (13, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 2), (13, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43506)$.", + "Output Answer": [ + "$14496$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43506))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $59^m \\equiv 1 \\pmod{216}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(59, 216))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6995}{2979}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{84427789}-6995}{5958}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6995/2979)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $192x \\equiv 1 \\pmod{527}$.", + "Output Answer": [ + "$398$" + ], + "Output Program": [ + "print(pow(192, -1, 527))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48544)$.", + "Output Answer": [ + "$23040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48544))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $206^m \\equiv 1 \\pmod{327}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(206, 327))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-29910$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-29910 % 30 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35339)$.", + "Output Answer": [ + "$35338$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35339))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1227)$.", + "Output Answer": [ + "$816$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1227))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $421x \\equiv 1 \\pmod{1785}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "print(pow(421, -1, 1785))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-439,-369\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -439, -369\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14420)$.", + "Output Answer": [ + "$4896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14420))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86399 \\pmod{5}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(86399 % 5)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-198,-13\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -198, -13\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16928 \\pmod{19}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(16928 % 19)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.574$ to base $4$.", + "Output Answer": [ + "$0.2102330123_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.574\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 13353 \\pmod{34}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(13353 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1786^2389 \\pmod{2537}$.", + "Output Answer": [ + "$1629$" + ], + "Output Program": [ + "print(pow(1786, 2389, 2537))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{7}$\n$x \\equiv 3 \\pmod{16}$", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 7), (3, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 7), (3, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 7), (3, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $893x \\equiv 1 \\pmod{924}$.", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "print(pow(893, -1, 924))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $94258$.", + "Output Answer": [ + "$2^1\\cdot 47129^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(94258))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46949)$.", + "Output Answer": [ + "$38016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46949))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $96557$.", + "Output Answer": [ + "$96557^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(96557))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-309,33\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -309, 33\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n23833", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(23833))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $733x \\equiv 1 \\pmod{1178}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(pow(733, -1, 1178))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $7x \\equiv 1 \\pmod{466}$.", + "Output Answer": [ + "$333$" + ], + "Output Program": [ + "print(pow(7, -1, 466))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 11 \\pmod{6}$\n$x \\equiv 17 \\pmod{9}$", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 5), (11, 6), (17, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 5), (11, 6), (17, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $569x \\equiv 1 \\pmod{1670}$.", + "Output Answer": [ + "$1309$" + ], + "Output Program": [ + "print(pow(569, -1, 1670))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.703$ to base $2$.", + "Output Answer": [ + "$0.10110011111101111101_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.703\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{8}$\n$x \\equiv 6 \\pmod{15}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "constraints = (12, 8), (6, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 8), (6, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 8), (6, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $419x \\equiv 1 \\pmod{672}$.", + "Output Answer": [ + "$587$" + ], + "Output Program": [ + "print(pow(419, -1, 672))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34595)$.", + "Output Answer": [ + "$23040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34595))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $755x \\equiv 1 \\pmod{1654}$.", + "Output Answer": [ + "$1229$" + ], + "Output Program": [ + "print(pow(755, -1, 1654))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 2 \\pmod{8}$\n$x \\equiv 20 \\pmod{2}$\n$x \\equiv 12 \\pmod{13}$", + "Output Answer": [ + "$298$" + ], + "Output Program": [ + "constraints = (16, 3), (2, 8), (20, 2), (12, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 3), (2, 8), (20, 2), (12, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3990}{253}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{253} \\left(\\sqrt{4044034}-1995\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3990/253)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $68859$.", + "Output Answer": [ + "$3^2\\cdot 7^1\\cdot 1093^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(68859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{19}$\n$x \\equiv 9 \\pmod{13}$", + "Output Answer": [ + "$230$" + ], + "Output Program": [ + "constraints = (2, 19), (9, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 19), (9, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 19), (9, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{94}{105}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{105} \\left(\\sqrt{13234}-47\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(94/105)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1762^404 \\pmod{2125}$.", + "Output Answer": [ + "$361$" + ], + "Output Program": [ + "print(pow(1762, 404, 2125))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21041)$.", + "Output Answer": [ + "$20592$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21041))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n43671", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43671))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-406$ is divisible by $7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-406 % 7 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $178^m \\equiv 1 \\pmod{497}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(178, 497))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n63707", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63707))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{10}$\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 18 \\pmod{13}$\n$x \\equiv 12 \\pmod{7}$", + "Output Answer": [ + "$369$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 10), (4, 5), (18, 13), (12, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 10), (4, 5), (18, 13), (12, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3614}{2289}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8504770}-1807}{2289}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3614/2289)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $473^m \\equiv 1 \\pmod{614}$.", + "Output Answer": [ + "$306$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(473, 614))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18621)$.", + "Output Answer": [ + "$12408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18621))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n24681", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24681))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-666,804\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -666, 804\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $33841$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(33841 % 43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 6 \\pmod{6}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 19), (6, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 19), (6, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 19), (6, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{16}$\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$6530$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 16), (20, 5), (4, 13), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 16), (20, 5), (4, 13), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 16), (20, 5), (4, 13), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.091$ to base $26$.", + "Output Answer": [ + "$\\text{0.29db}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.091\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{2}$\n$x \\equiv 7 \\pmod{11}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (2, 2), (7, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 2), (7, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 2), (7, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1363^2223 \\pmod{2842}$.", + "Output Answer": [ + "$2001$" + ], + "Output Program": [ + "print(pow(1363, 2223, 2842))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14104}{2301}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{55025305}-7052}{2301}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14104/2301)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8854}{8875}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{98363954}-4427}{8875}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8854/8875)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9238)$.", + "Output Answer": [ + "$4440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9238))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-27173$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-27173 % -29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19842)$.", + "Output Answer": [ + "$6612$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19842))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $760^774 \\pmod{1188}$.", + "Output Answer": [ + "$892$" + ], + "Output Program": [ + "print(pow(760, 774, 1188))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8054}{4473}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{36224458}-4027}{4473}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8054/4473)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46499)$.", + "Output Answer": [ + "$46498$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46499))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{164,-755,566\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 164, -755, 566\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1525}{3627}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{54946141}-1525}{7254}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1525/3627)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{59,820,-200\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 59, 820, -200\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 19 \\pmod{15}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 2), (19, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 2), (19, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 2), (19, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25640)$.", + "Output Answer": [ + "$10240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25640))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $123^m \\equiv 1 \\pmod{770}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(123, 770))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2741}{35750}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5119763081}-2741}{71500}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2741/35750)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n11257", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(11257))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $119x \\equiv 1 \\pmod{1038}$.", + "Output Answer": [ + "$881$" + ], + "Output Program": [ + "print(pow(119, -1, 1038))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $947x \\equiv 1 \\pmod{968}$.", + "Output Answer": [ + "$507$" + ], + "Output Program": [ + "print(pow(947, -1, 968))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-743,-504\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -743, -504\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1633^163 \\pmod{1780}$.", + "Output Answer": [ + "$1417$" + ], + "Output Program": [ + "print(pow(1633, 163, 1780))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-69,-542\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -69, -542\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{10011}{13421}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{820713085}-10011}{26842}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10011/13421)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17695)$.", + "Output Answer": [ + "$14152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17695))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{498,111,-157\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 498, 111, -157\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-40$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-40 % 19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n80791", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(80791))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1151^222 \\pmod{2038}$.", + "Output Answer": [ + "$627$" + ], + "Output Program": [ + "print(pow(1151, 222, 2038))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $9973$.", + "Output Answer": [ + "$\\{11,13,17,23,29,31,33,37,39,44\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(9973):\n if len(roots) == 10: break\n if gcd(a, 9973) == 1 and is_primitive_root(a, 9973):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71703 \\pmod{39}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(71703 % 39)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-218,540,187\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -218, 540, 187\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1875^2028 \\pmod{2692}$.", + "Output Answer": [ + "$1293$" + ], + "Output Program": [ + "print(pow(1875, 2028, 2692))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $240^m \\equiv 1 \\pmod{983}$.", + "Output Answer": [ + "$982$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(240, 983))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $294^635 \\pmod{713}$.", + "Output Answer": [ + "$154$" + ], + "Output Program": [ + "print(pow(294, 635, 713))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $319^m \\equiv 1 \\pmod{773}$.", + "Output Answer": [ + "$772$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(319, 773))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17957}{24360}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2696092249}-17957}{48720}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17957/24360)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30947)$.", + "Output Answer": [ + "$26520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30947))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17954)$.", + "Output Answer": [ + "$8740$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17954))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1132^1197 \\pmod{2202}$.", + "Output Answer": [ + "$472$" + ], + "Output Program": [ + "print(pow(1132, 1197, 2202))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $3^2387 \\pmod{476}$.", + "Output Answer": [ + "$299$" + ], + "Output Program": [ + "print(pow(3, 2387, 476))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $643^772 \\pmod{1829}$.", + "Output Answer": [ + "$281$" + ], + "Output Program": [ + "print(pow(643, 772, 1829))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $116^m \\equiv 1 \\pmod{799}$.", + "Output Answer": [ + "$368$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(116, 799))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{8}$\n$x \\equiv 10 \\pmod{18}$\n$x \\equiv 14 \\pmod{5}$\n$x \\equiv 4 \\pmod{13}$", + "Output Answer": [ + "$4294$" + ], + "Output Program": [ + "constraints = (6, 8), (10, 18), (14, 5), (4, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 8), (10, 18), (14, 5), (4, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38527 \\pmod{21}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(38527 % 21)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 0 \\pmod{17}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 4), (0, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 4), (0, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 4), (0, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38084)$.", + "Output Answer": [ + "$19040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38084))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5455}{1184}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{35364449}-5455}{2368}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5455/1184)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48455 \\pmod{63}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(48455 % 63)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $167x \\equiv 1 \\pmod{1182}$.", + "Output Answer": [ + "$545$" + ], + "Output Program": [ + "print(pow(167, -1, 1182))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $475^1723 \\pmod{2274}$.", + "Output Answer": [ + "$1087$" + ], + "Output Program": [ + "print(pow(475, 1723, 2274))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{2}$\n$x \\equiv 16 \\pmod{9}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 2), (16, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 2), (16, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 2), (16, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-603,377,-486\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -603, 377, -486\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $231^m \\equiv 1 \\pmod{811}$.", + "Output Answer": [ + "$810$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(231, 811))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47606 \\pmod{98}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "print(47606 % 98)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1187$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1187 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{10}$\n$x \\equiv 19 \\pmod{12}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "constraints = (1, 10), (19, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 10), (19, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $323^m \\equiv 1 \\pmod{586}$.", + "Output Answer": [ + "$292$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(323, 586))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{715}{522}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1601161}-715}{1044}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(715/522)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19797)$.", + "Output Answer": [ + "$13196$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19797))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2050^1498 \\pmod{2165}$.", + "Output Answer": [ + "$1065$" + ], + "Output Program": [ + "print(pow(2050, 1498, 2165))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $369^1869 \\pmod{617}$.", + "Output Answer": [ + "$344$" + ], + "Output Program": [ + "print(pow(369, 1869, 617))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{12583}{893}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{161521685}-12583}{1786}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12583/893)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-299,-720\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -299, -720\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57000 \\pmod{71}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "print(57000 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $48x \\equiv 1 \\pmod{1867}$.", + "Output Answer": [ + "$1128$" + ], + "Output Program": [ + "print(pow(48, -1, 1867))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $763^1154 \\pmod{2239}$.", + "Output Answer": [ + "$553$" + ], + "Output Program": [ + "print(pow(763, 1154, 2239))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n38369", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(38369))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17198 \\pmod{4}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(17198 % 4)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21728)$.", + "Output Answer": [ + "$9216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21728))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-3,-3,2,-5\\}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "import math\n\nvalues = -3, -3, 2, -5\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1246$ is divisible by $29$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1246 % 29 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9375)$.", + "Output Answer": [ + "$5000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9375))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-945,-150,148\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -945, -150, 148\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63346 \\pmod{78}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(63346 % 78)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-745,-429,-130\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -745, -429, -130\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{843,398\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 843, 398\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1525$ to base $12$.", + "Output Answer": [ + "$\\text{a71}_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1525\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20070)$.", + "Output Answer": [ + "$5328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20070))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{224,50,49\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 224, 50, 49\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $194x \\equiv 1 \\pmod{1435}$.", + "Output Answer": [ + "$969$" + ], + "Output Program": [ + "print(pow(194, -1, 1435))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n98141", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(98141))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $4943$.", + "Output Answer": [ + "$\\{7,10,11,15,20,22,28,30,31,33\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(4943):\n if len(roots) == 10: break\n if gcd(a, 4943) == 1 and is_primitive_root(a, 4943):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-426,452,335\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -426, 452, 335\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-956,943,818\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -956, 943, 818\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-389,230\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -389, 230\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $22982$.", + "Output Answer": [ + "$\\{3,7,15,33,35,39,41,43,51,59\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(22982):\n if len(roots) == 10: break\n if gcd(a, 22982) == 1 and is_primitive_root(a, 22982):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{241}{9978}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{398300017}-241}{19956}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(241/9978)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1214^837 \\pmod{1559}$.", + "Output Answer": [ + "$176$" + ], + "Output Program": [ + "print(pow(1214, 837, 1559))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $437x \\equiv 1 \\pmod{1314}$.", + "Output Answer": [ + "$875$" + ], + "Output Program": [ + "print(pow(437, -1, 1314))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.76$ to base $12$.", + "Output Answer": [ + "$0.915344_{12}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 12\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.76\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n60491", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60491))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1847^2231 \\pmod{2121}$.", + "Output Answer": [ + "$1301$" + ], + "Output Program": [ + "print(pow(1847, 2231, 2121))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $14555_6$ to base 10.", + "Output Answer": [ + "$2375$" + ], + "Output Program": [ + "n = '14555'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n102985", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102985))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1290^1034 \\pmod{2465}$.", + "Output Answer": [ + "$990$" + ], + "Output Program": [ + "print(pow(1290, 1034, 2465))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68578 \\pmod{69}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(68578 % 69)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-816,618,373\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -816, 618, 373\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37110)$.", + "Output Answer": [ + "$9888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37110))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2443^149 \\pmod{2678}$.", + "Output Answer": [ + "$1715$" + ], + "Output Program": [ + "print(pow(2443, 149, 2678))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88787 \\pmod{85}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(88787 % 85)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{15}$\n$x \\equiv 14 \\pmod{9}$\n$x \\equiv 17 \\pmod{2}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 15), (14, 9), (17, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 15), (14, 9), (17, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2476)$.", + "Output Answer": [ + "$1236$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2476))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 18 \\pmod{16}$", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (18, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 7), (18, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 7), (18, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{8,-11,327\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 8, -11, 327\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $496^485 \\pmod{2183}$.", + "Output Answer": [ + "$809$" + ], + "Output Program": [ + "print(pow(496, 485, 2183))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $59789$.", + "Output Answer": [ + "$17^1\\cdot 3517^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(59789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2416$ to base $30$.", + "Output Answer": [ + "$\\text{2kg}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2416\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-198,743\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -198, 743\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44792)$.", + "Output Answer": [ + "$20320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44792))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-667,901,197\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -667, 901, 197\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1109x \\equiv 1 \\pmod{2462}$.", + "Output Answer": [ + "$2351$" + ], + "Output Program": [ + "print(pow(1109, -1, 2462))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 0 \\pmod{18}$\n$x \\equiv 1 \\pmod{17}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (11, 7), (0, 18), (1, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (0, 18), (1, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 7), (0, 18), (1, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36621 \\pmod{34}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(36621 % 34)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $901^1940 \\pmod{2012}$.", + "Output Answer": [ + "$1017$" + ], + "Output Program": [ + "print(pow(901, 1940, 2012))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14456}{9149}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{135948185}-7228}{9149}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14456/9149)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $393^m \\equiv 1 \\pmod{743}$.", + "Output Answer": [ + "$371$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(393, 743))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12526)$.", + "Output Answer": [ + "$6262$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12526))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{640,-67,369\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 640, -67, 369\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $147^m \\equiv 1 \\pmod{838}$.", + "Output Answer": [ + "$209$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(147, 838))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1505^80 \\pmod{2357}$.", + "Output Answer": [ + "$736$" + ], + "Output Program": [ + "print(pow(1505, 80, 2357))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31975)$.", + "Output Answer": [ + "$25560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31975))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-9336$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-9336 % -36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1292^2066 \\pmod{2298}$.", + "Output Answer": [ + "$1318$" + ], + "Output Program": [ + "print(pow(1292, 2066, 2298))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-21336$ is divisible by $21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-21336 % 21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2606$ to base $36$.", + "Output Answer": [ + "$\\text{20e}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2606\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-637$ is divisible by $41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-637 % 41 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n99731", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(99731))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $24^m \\equiv 1 \\pmod{29}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(24, 29))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6913)$.", + "Output Answer": [ + "$6660$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6913))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-39134$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-39134 % 34 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{17047}{34723}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{204533885}-17047}{69446}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17047/34723)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{6552}{2689}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{17962897}-3276}{2689}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6552/2689)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{13}$\n$x \\equiv 17 \\pmod{19}$", + "Output Answer": [ + "$188$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 13), (17, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 13), (17, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 13), (17, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n18047", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18047))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $247^m \\equiv 1 \\pmod{888}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(247, 888))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{993,-319\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 993, -319\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5279}{3707}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{82835237}-5279}{7414}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5279/3707)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $28723$.", + "Output Answer": [ + "$\\{2,3,5,13,17,20,22,28,30,32\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(28723):\n if len(roots) == 10: break\n if gcd(a, 28723) == 1 and is_primitive_root(a, 28723):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{3}$\n$x \\equiv 5 \\pmod{13}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "constraints = (5, 3), (5, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 3), (5, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 3), (5, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $26^1363 \\pmod{2704}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(pow(26, 1363, 2704))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-1,2\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -1, 2\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53507$.", + "Output Answer": [ + "$\\{2,5,6,8,11,14,15,18,20,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53507):\n if len(roots) == 10: break\n if gcd(a, 53507) == 1 and is_primitive_root(a, 53507):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4881}{2659}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{52105285}-4881}{5318}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4881/2659)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-48528$ is divisible by $36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-48528 % 36 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-49998$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-49998 % 39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24689 \\pmod{38}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(24689 % 38)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1270$ to base $11$.", + "Output Answer": [ + "$\\text{a55}_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1270\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.$ to base $16$.", + "Output Answer": [ + "$0._{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1691^2060 \\pmod{2717}$.", + "Output Answer": [ + "$2432$" + ], + "Output Program": [ + "print(pow(1691, 2060, 2717))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{950,849,222\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 950, 849, 222\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $97x \\equiv 1 \\pmod{705}$.", + "Output Answer": [ + "$298$" + ], + "Output Program": [ + "print(pow(97, -1, 705))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8030}{29303}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{874786034}-4015}{29303}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8030/29303)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40498 \\pmod{89}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(40498 % 89)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2019^1840 \\pmod{2045}$.", + "Output Answer": [ + "$286$" + ], + "Output Program": [ + "print(pow(2019, 1840, 2045))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1033^1570 \\pmod{2375}$.", + "Output Answer": [ + "$1774$" + ], + "Output Program": [ + "print(pow(1033, 1570, 2375))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-771$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-771 % -17 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1129^163 \\pmod{2156}$.", + "Output Answer": [ + "$2081$" + ], + "Output Program": [ + "print(pow(1129, 163, 2156))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{33164}{5}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{5} \\left(\\sqrt{274962749}-16582\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33164/5)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31074 \\pmod{52}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(31074 % 52)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $204^2245 \\pmod{1572}$.", + "Output Answer": [ + "$1440$" + ], + "Output Program": [ + "print(pow(204, 2245, 1572))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $88^718 \\pmod{1982}$.", + "Output Answer": [ + "$1616$" + ], + "Output Program": [ + "print(pow(88, 718, 1982))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1224^2117 \\pmod{1738}$.", + "Output Answer": [ + "$856$" + ], + "Output Program": [ + "print(pow(1224, 2117, 1738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-46694$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-46694 % 37 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 0 \\pmod{16}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 3), (4, 2), (8, 19), (0, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 3), (4, 2), (8, 19), (0, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $629x \\equiv 1 \\pmod{2425}$.", + "Output Answer": [ + "$1519$" + ], + "Output Program": [ + "print(pow(629, -1, 2425))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $544^m \\equiv 1 \\pmod{709}$.", + "Output Answer": [ + "$118$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(544, 709))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1049x \\equiv 1 \\pmod{1445}$.", + "Output Answer": [ + "$894$" + ], + "Output Program": [ + "print(pow(1049, -1, 1445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $242^156 \\pmod{1783}$.", + "Output Answer": [ + "$1700$" + ], + "Output Program": [ + "print(pow(242, 156, 1783))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10991)$.", + "Output Answer": [ + "$10584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10991))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{10}$\n$x \\equiv 19 \\pmod{17}$\n$x \\equiv 13 \\pmod{12}$", + "Output Answer": [ + "$325$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 10), (19, 17), (13, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 10), (19, 17), (13, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{6}$\n$x \\equiv 6 \\pmod{4}$\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 18 \\pmod{4}$", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 6), (6, 4), (15, 11), (18, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 6), (6, 4), (15, 11), (18, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $79^m \\equiv 1 \\pmod{238}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(79, 238))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $79196$.", + "Output Answer": [ + "$2^2\\cdot 13^1\\cdot 1523^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(79196))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{8528}{2287}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{23412065}-4264}{2287}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8528/2287)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $112x \\equiv 1 \\pmod{1487}$.", + "Output Answer": [ + "$863$" + ], + "Output Program": [ + "print(pow(112, -1, 1487))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $227x \\equiv 1 \\pmod{417}$.", + "Output Answer": [ + "$248$" + ], + "Output Program": [ + "print(pow(227, -1, 417))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62245 \\pmod{30}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(62245 % 30)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $571x \\equiv 1 \\pmod{1553}$.", + "Output Answer": [ + "$1058$" + ], + "Output Program": [ + "print(pow(571, -1, 1553))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3362}{1983}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{270322}-1681}{1983}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3362/1983)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1698^1065 \\pmod{1962}$.", + "Output Answer": [ + "$1854$" + ], + "Output Program": [ + "print(pow(1698, 1065, 1962))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{12}$\n$x \\equiv 18 \\pmod{2}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 12), (18, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 12), (18, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 13 \\pmod{9}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 3), (13, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 3), (13, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1668^1479 \\pmod{2108}$.", + "Output Answer": [ + "$1148$" + ], + "Output Program": [ + "print(pow(1668, 1479, 2108))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32970)$.", + "Output Answer": [ + "$7488$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32970))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-674,72\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -674, 72\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{18}$\n$x \\equiv 8 \\pmod{2}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "constraints = (20, 18), (8, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 18), (8, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1927$ to base $2$.", + "Output Answer": [ + "$11110000111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1927\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $242$ is divisible by $46$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(242 % 46 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5345 \\pmod{17}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(5345 % 17)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62127 \\pmod{64}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(62127 % 64)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49750)$.", + "Output Answer": [ + "$19800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49750))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{88,386,67\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 88, 386, 67\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $299^m \\equiv 1 \\pmod{555}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(299, 555))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $353^m \\equiv 1 \\pmod{423}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(353, 423))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1318^2416 \\pmod{1397}$.", + "Output Answer": [ + "$1120$" + ], + "Output Program": [ + "print(pow(1318, 2416, 1397))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{19}$\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 7 \\pmod{6}$\n$x \\equiv 17 \\pmod{5}$", + "Output Answer": [ + "$4297$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 19), (7, 11), (7, 6), (17, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 19), (7, 11), (7, 6), (17, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 19), (7, 11), (7, 6), (17, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1376}{2717}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7855433}-688}{2717}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1376/2717)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76293 \\pmod{19}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(76293 % 19)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1428$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1428 % -14 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28661)$.", + "Output Answer": [ + "$28660$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28661))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61141 \\pmod{96}$.", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "print(61141 % 96)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{30342}{5899}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{264957442}-15171}{5899}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30342/5899)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-49303$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-49303 % 47 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11616)$.", + "Output Answer": [ + "$3520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11616))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71407 \\pmod{72}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(71407 % 72)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-3570$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3570 % -21 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31229)$.", + "Output Answer": [ + "$26560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31229))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $91457$.", + "Output Answer": [ + "$91457^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(91457))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2506)$.", + "Output Answer": [ + "$1068$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2506))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n53281", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53281))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{902,-271\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 902, -271\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{9}$\n$x \\equiv 5 \\pmod{20}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 1 \\pmod{8}$", + "Output Answer": [ + "$945$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 9), (5, 20), (7, 7), (1, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 9), (5, 20), (7, 7), (1, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{277}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 277))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1615^556 \\pmod{2642}$.", + "Output Answer": [ + "$341$" + ], + "Output Program": [ + "print(pow(1615, 556, 2642))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $145x \\equiv 1 \\pmod{336}$.", + "Output Answer": [ + "$241$" + ], + "Output Program": [ + "print(pow(145, -1, 336))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n94533", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(94533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $437^m \\equiv 1 \\pmod{525}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(437, 525))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n52903", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(52903))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1825x \\equiv 1 \\pmod{2411}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "print(pow(1825, -1, 2411))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8281 \\pmod{54}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(8281 % 54)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.569$ to base $3$.", + "Output Answer": [ + "$0.120100210122_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.569\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.45$ to base $16$.", + "Output Answer": [ + "$0.73333_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.45\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{161,544,93\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 161, 544, 93\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{27332}{17803}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{503706365}-13666}{17803}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27332/17803)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n104289", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(104289))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-434,521,-849\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -434, 521, -849\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $141x \\equiv 1 \\pmod{1948}$.", + "Output Answer": [ + "$525$" + ], + "Output Program": [ + "print(pow(141, -1, 1948))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $49^m \\equiv 1 \\pmod{390}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(49, 390))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1185^1024 \\pmod{1539}$.", + "Output Answer": [ + "$729$" + ], + "Output Program": [ + "print(pow(1185, 1024, 1539))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $749^m \\equiv 1 \\pmod{855}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(749, 855))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22356}{7757}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{185118733}-11178}{7757}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22356/7757)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $830^1222 \\pmod{1748}$.", + "Output Answer": [ + "$1244$" + ], + "Output Program": [ + "print(pow(830, 1222, 1748))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-834,342\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -834, 342\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34659)$.", + "Output Answer": [ + "$23100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34659))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $721^133 \\pmod{1585}$.", + "Output Answer": [ + "$321$" + ], + "Output Program": [ + "print(pow(721, 133, 1585))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{12}$\n$x \\equiv 12 \\pmod{9}$\n$x \\equiv 19 \\pmod{19}$", + "Output Answer": [ + "$570$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 12), (12, 9), (19, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 12), (12, 9), (19, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $691^m \\equiv 1 \\pmod{728}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(691, 728))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $303^m \\equiv 1 \\pmod{550}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(303, 550))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{2}$\n$x \\equiv 3 \\pmod{12}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 2), (3, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 2), (3, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{11}$\n$x \\equiv 15 \\pmod{4}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 11), (15, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 11), (15, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 11), (15, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $81x \\equiv 1 \\pmod{292}$.", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "print(pow(81, -1, 292))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64863 \\pmod{16}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(64863 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $145^m \\equiv 1 \\pmod{177}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(145, 177))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $434_8$ to base 10.", + "Output Answer": [ + "$284$" + ], + "Output Program": [ + "n = '434'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $514x \\equiv 1 \\pmod{2217}$.", + "Output Answer": [ + "$358$" + ], + "Output Program": [ + "print(pow(514, -1, 2217))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $98343$.", + "Output Answer": [ + "$3^2\\cdot 7^2\\cdot 223^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(98343))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{816,-464,973\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 816, -464, 973\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-786,-812,-473\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -786, -812, -473\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2075^1113 \\pmod{2136}$.", + "Output Answer": [ + "$1163$" + ], + "Output Program": [ + "print(pow(2075, 1113, 2136))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $275x \\equiv 1 \\pmod{651}$.", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "print(pow(275, -1, 651))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48485)$.", + "Output Answer": [ + "$38784$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48485))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3)$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{15916}{8387}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{133671533}-7958}{8387}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15916/8387)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{102,-281\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 102, -281\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $10332_5$ to base 10.", + "Output Answer": [ + "$717$" + ], + "Output Program": [ + "n = '10332'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38070 \\pmod{82}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(38070 % 82)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $2^m \\equiv 1 \\pmod{263}$.", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(2, 263))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-973,92,-997\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -973, 92, -997\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $39^m \\equiv 1 \\pmod{122}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(39, 122))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $667x \\equiv 1 \\pmod{1738}$.", + "Output Answer": [ + "$1097$" + ], + "Output Program": [ + "print(pow(667, -1, 1738))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $769x \\equiv 1 \\pmod{1633}$.", + "Output Answer": [ + "$1272$" + ], + "Output Program": [ + "print(pow(769, -1, 1633))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-36,-540\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -36, -540\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-8558$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-8558 % -44 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2077x \\equiv 1 \\pmod{2215}$.", + "Output Answer": [ + "$1268$" + ], + "Output Program": [ + "print(pow(2077, -1, 2215))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71960 \\pmod{47}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(71960 % 47)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{15813}{9232}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{590970265}-15813}{18464}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15813/9232)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11913 \\pmod{6}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(11913 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{515,-258\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 515, -258\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $165x \\equiv 1 \\pmod{377}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(pow(165, -1, 377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{15}$\n$x \\equiv 15 \\pmod{16}$\n$x \\equiv 19 \\pmod{14}$", + "Output Answer": [ + "$1391$" + ], + "Output Program": [ + "constraints = (11, 15), (15, 16), (19, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 15), (15, 16), (19, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9425)$.", + "Output Answer": [ + "$6720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9425))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $70330$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 13^1\\cdot 541^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(70330))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2241^2009 \\pmod{2456}$.", + "Output Answer": [ + "$1345$" + ], + "Output Program": [ + "print(pow(2241, 2009, 2456))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1213^1596 \\pmod{1652}$.", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "print(pow(1213, 1596, 1652))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{14294}{4135}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{68177834}-7147}{4135}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14294/4135)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{23,699\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 23, 699\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $1855$ to base $32$.", + "Output Answer": [ + "$\\text{1pv}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1855\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{197}{28}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{56} \\left(\\sqrt{41945}-197\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(197/28)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39214)$.", + "Output Answer": [ + "$16800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39214))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n102293", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102293))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $535x \\equiv 1 \\pmod{606}$.", + "Output Answer": [ + "$367$" + ], + "Output Program": [ + "print(pow(535, -1, 606))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $284^1896 \\pmod{790}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "print(pow(284, 1896, 790))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2821}{1017}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{12095197}-2821}{2034}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2821/1017)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29200)$.", + "Output Answer": [ + "$11520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29200))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $22046$.", + "Output Answer": [ + "$2^1\\cdot 73^1\\cdot 151^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(22046))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1819^219 \\pmod{2859}$.", + "Output Answer": [ + "$2290$" + ], + "Output Program": [ + "print(pow(1819, 219, 2859))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $222^m \\equiv 1 \\pmod{473}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(222, 473))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{7}$\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 1 \\pmod{10}$", + "Output Answer": [ + "$631$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 7), (2, 17), (1, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 7), (2, 17), (1, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 7), (2, 17), (1, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $709x \\equiv 1 \\pmod{2382}$.", + "Output Answer": [ + "$1999$" + ], + "Output Program": [ + "print(pow(709, -1, 2382))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54517 \\pmod{67}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(54517 % 67)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-661,-810,617\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -661, -810, 617\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23488)$.", + "Output Answer": [ + "$11712$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23488))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $28260$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(28260 % -45 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1206^1081 \\pmod{2279}$.", + "Output Answer": [ + "$997$" + ], + "Output Program": [ + "print(pow(1206, 1081, 2279))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20567)$.", + "Output Answer": [ + "$20280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20567))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 3), (16, 11), (10, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (16, 11), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 3), (16, 11), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52324 \\pmod{23}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(52324 % 23)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $15884$ is divisible by $22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(15884 % 22 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $91361$.", + "Output Answer": [ + "$103^1\\cdot 887^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(91361))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-175,-720,9\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -175, -720, 9\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.083$ to base $29$.", + "Output Answer": [ + "$\\text{0.2bn8}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.083\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1340x \\equiv 1 \\pmod{1521}$.", + "Output Answer": [ + "$521$" + ], + "Output Program": [ + "print(pow(1340, -1, 1521))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $110^2106 \\pmod{1667}$.", + "Output Answer": [ + "$827$" + ], + "Output Program": [ + "print(pow(110, 2106, 1667))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{238,758\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 238, 758\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57468 \\pmod{6}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(57468 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1307$ is divisible by $42$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1307 % 42 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48781)$.", + "Output Answer": [ + "$48780$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48781))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 6 \\pmod{9}$\n$x \\equiv 13 \\pmod{8}$", + "Output Answer": [ + "$213$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 11), (18, 5), (6, 9), (13, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 11), (18, 5), (6, 9), (13, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 11), (18, 5), (6, 9), (13, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 15 \\pmod{18}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 5), (15, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 5), (15, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (5, 5), (15, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2269}{665}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6917261}-2269}{1330}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2269/665)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2230$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2230 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30377)$.", + "Output Answer": [ + "$29520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30377))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $7x \\equiv 1 \\pmod{268}$.", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "print(pow(7, -1, 268))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8850)$.", + "Output Answer": [ + "$2320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8850))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93098 \\pmod{70}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(93098 % 70)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $464_{25}$ to base 10.", + "Output Answer": [ + "$2654$" + ], + "Output Program": [ + "n = '464'.strip('.')\nbase = 25\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $325x \\equiv 1 \\pmod{382}$.", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "print(pow(325, -1, 382))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16256)$.", + "Output Answer": [ + "$8064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16256))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7100)$.", + "Output Answer": [ + "$2800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7100))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{6}$\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 6), (14, 13), (6, 5), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 6), (14, 13), (6, 5), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1654}{2513}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6999098}-827}{2513}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1654/2513)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $82^m \\equiv 1 \\pmod{639}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(82, 639))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $817^2142 \\pmod{2995}$.", + "Output Answer": [ + "$1154$" + ], + "Output Program": [ + "print(pow(817, 2142, 2995))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $2383$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2383 % -49 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40469 \\pmod{88}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(40469 % 88)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $249$ to base $19$.", + "Output Answer": [ + "$\\text{d2}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 249\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 15 \\pmod{8}$", + "Output Answer": [ + "$151$" + ], + "Output Program": [ + "constraints = (18, 19), (15, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 19), (15, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (15, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39198)$.", + "Output Answer": [ + "$12696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39198))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4090$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-4090 % -25 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $213^m \\equiv 1 \\pmod{329}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(213, 329))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-2397$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2397 % -48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3268}{889}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{889} \\left(\\sqrt{3460277}-1634\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3268/889)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19381)$.", + "Output Answer": [ + "$19380$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19381))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $916^2244 \\pmod{1605}$.", + "Output Answer": [ + "$1081$" + ], + "Output Program": [ + "print(pow(916, 2244, 1605))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $258^1043 \\pmod{1520}$.", + "Output Answer": [ + "$672$" + ], + "Output Program": [ + "print(pow(258, 1043, 1520))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49410 \\pmod{75}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(49410 % 75)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{785}{1356}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7971169}-785}{2712}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(785/1356)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $472^m \\equiv 1 \\pmod{729}$.", + "Output Answer": [ + "$243$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(472, 729))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{941,627\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 941, 627\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2372$ to base $14$.", + "Output Answer": [ + "$\\text{c16}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2372\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $142^1220 \\pmod{2906}$.", + "Output Answer": [ + "$2520$" + ], + "Output Program": [ + "print(pow(142, 1220, 2906))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-37908$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-37908 % -39 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{19}$\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$200$" + ], + "Output Program": [ + "constraints = (10, 19), (2, 11), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 19), (2, 11), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n4351", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4351))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{958,-290,411\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 958, -290, 411\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{502,72,157\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 502, 72, 157\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $64200$.", + "Output Answer": [ + "$2^3\\cdot 3^1\\cdot 5^2\\cdot 107^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(64200))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $203^m \\equiv 1 \\pmod{209}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(203, 209))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{9083}{1438}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{90772265}-9083}{2876}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9083/1438)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1376^2471 \\pmod{1798}$.", + "Output Answer": [ + "$1478$" + ], + "Output Program": [ + "print(pow(1376, 2471, 1798))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $37808$.", + "Output Answer": [ + "$2^4\\cdot 17^1\\cdot 139^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37808))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,4,-4\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 4, -4\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{239,176\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 239, 176\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $94^m \\equiv 1 \\pmod{315}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(94, 315))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59163 \\pmod{6}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(59163 % 6)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 2), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 2), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 2), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92585 \\pmod{51}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(92585 % 51)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $18394$.", + "Output Answer": [ + "$2^1\\cdot 17^1\\cdot 541^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(18394))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1433)$.", + "Output Answer": [ + "$1432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1433))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{2464}{885}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{885} \\left(\\sqrt{2301049}-1232\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2464/885)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{11331}{3947}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{190706797}-11331}{7894}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11331/3947)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{4,1,-3\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = 4, 1, -3\nprint(math.lcm(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29153)$.", + "Output Answer": [ + "$29152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29153))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25116 \\pmod{84}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(25116 % 84)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3522 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(3522 % 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{405,-891,1\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 405, -891, 1\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3341}{9759}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{392114605}-3341}{19518}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3341/9759)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $121x \\equiv 1 \\pmod{384}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(121, -1, 384))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 18 \\pmod{17}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 11), (18, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 11), (18, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 11), (18, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27216)$.", + "Output Answer": [ + "$7776$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27216))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47362)$.", + "Output Answer": [ + "$19008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47362))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59474 \\pmod{16}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(59474 % 16)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $30783$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(30783 % 31 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{10}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "constraints = (12, 10), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 10), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 10), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $214^m \\equiv 1 \\pmod{821}$.", + "Output Answer": [ + "$410$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(214, 821))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{51}{56}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{112} \\left(\\sqrt{15145}-51\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(51/56)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2461^1900 \\pmod{2475}$.", + "Output Answer": [ + "$1651$" + ], + "Output Program": [ + "print(pow(2461, 1900, 2475))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $58258$.", + "Output Answer": [ + "$\\{3,15,19,27,33,39,41,43,51,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(58258):\n if len(roots) == 10: break\n if gcd(a, 58258) == 1 and is_primitive_root(a, 58258):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{656,129,-581\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 656, 129, -581\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{184}{753}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{753} \\left(\\sqrt{575473}-92\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(184/753)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{37683}{2138}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1438292665}-37683}{4276}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37683/2138)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44826 \\pmod{22}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(44826 % 22)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20937)$.", + "Output Answer": [ + "$11952$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20937))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13784)$.", + "Output Answer": [ + "$6888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13784))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $37597$.", + "Output Answer": [ + "$7^1\\cdot 41^1\\cdot 131^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37597))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{658,-641\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 658, -641\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1211x \\equiv 1 \\pmod{2286}$.", + "Output Answer": [ + "$353$" + ], + "Output Program": [ + "print(pow(1211, -1, 2286))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40014 \\pmod{99}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(40014 % 99)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $421^m \\equiv 1 \\pmod{587}$.", + "Output Answer": [ + "$293$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(421, 587))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $706x \\equiv 1 \\pmod{1759}$.", + "Output Answer": [ + "$147$" + ], + "Output Program": [ + "print(pow(706, -1, 1759))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66929 \\pmod{10}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(66929 % 10)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2018^1989 \\pmod{2395}$.", + "Output Answer": [ + "$688$" + ], + "Output Program": [ + "print(pow(2018, 1989, 2395))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{635}$.", + "Output Answer": [ + "$252$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 635))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4160}{13213}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{178909769}-2080}{13213}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4160/13213)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{1,-1,491\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 1, -1, 491\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1848$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1848 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $9179$.", + "Output Answer": [ + "$67^1\\cdot 137^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(9179))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $900^2124 \\pmod{1104}$.", + "Output Answer": [ + "$624$" + ], + "Output Program": [ + "print(pow(900, 2124, 1104))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-967,-130\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -967, -130\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82835 \\pmod{71}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(82835 % 71)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22180 \\pmod{97}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(22180 % 97)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1218x \\equiv 1 \\pmod{1445}$.", + "Output Answer": [ + "$592$" + ], + "Output Program": [ + "print(pow(1218, -1, 1445))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $934$ to base $9$.", + "Output Answer": [ + "$1247_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 934\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{22371}{39193}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6644826637}-22371}{78386}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22371/39193)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47716)$.", + "Output Answer": [ + "$23400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47716))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $17518$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(17518 % -19 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $54138$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 7^1\\cdot 1289^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(54138))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45017)$.", + "Output Answer": [ + "$37584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45017))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $2473$ to base $25$.", + "Output Answer": [ + "$\\text{3nn}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2473\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-958,942\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -958, 942\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31111)$.", + "Output Answer": [ + "$30472$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31111))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n20789", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(20789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62447 \\pmod{15}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(62447 % 15)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{419}{217}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{434} \\left(\\sqrt{363917}-419\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(419/217)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{927,-595\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 927, -595\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{5612}{12597}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{166558045}-2806}{12597}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5612/12597)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $285^m \\equiv 1 \\pmod{386}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(285, 386))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $862x \\equiv 1 \\pmod{1887}$.", + "Output Answer": [ + "$1285$" + ], + "Output Program": [ + "print(pow(862, -1, 1887))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59473 \\pmod{83}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(59473 % 83)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1199x \\equiv 1 \\pmod{2410}$.", + "Output Answer": [ + "$2209$" + ], + "Output Program": [ + "print(pow(1199, -1, 2410))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4803}{10804}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{489974473}-4803}{21608}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4803/10804)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $375$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(375 % 32 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{12}$\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 0 \\pmod{16}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 12), (5, 5), (0, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 12), (5, 5), (0, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31268)$.", + "Output Answer": [ + "$15632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31268))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16881)$.", + "Output Answer": [ + "$10560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16881))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40902)$.", + "Output Answer": [ + "$12800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40902))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $151x \\equiv 1 \\pmod{2108}$.", + "Output Answer": [ + "$1759$" + ], + "Output Program": [ + "print(pow(151, -1, 2108))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $115x \\equiv 1 \\pmod{683}$.", + "Output Answer": [ + "$196$" + ], + "Output Program": [ + "print(pow(115, -1, 683))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.4351564_7$ to base 10.", + "Output Answer": [ + "$0.648$" + ], + "Output Program": [ + "n = '0.4351564'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $583$ to base $30$.", + "Output Answer": [ + "$\\text{jd}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 583\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-4$ is divisible by $16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-4 % 16 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $724^2247 \\pmod{1015}$.", + "Output Answer": [ + "$1014$" + ], + "Output Program": [ + "print(pow(724, 2247, 1015))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 2 \\pmod{15}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 4), (2, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 4), (2, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 4), (2, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{159,-384\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 159, -384\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $169^m \\equiv 1 \\pmod{170}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(169, 170))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2215^703 \\pmod{2540}$.", + "Output Answer": [ + "$1875$" + ], + "Output Program": [ + "print(pow(2215, 703, 2540))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{10}$\n$x \\equiv 12 \\pmod{17}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$573$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 10), (12, 17), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 10), (12, 17), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 10), (12, 17), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33361 \\pmod{88}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(33361 % 88)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $281x \\equiv 1 \\pmod{1988}$.", + "Output Answer": [ + "$757$" + ], + "Output Program": [ + "print(pow(281, -1, 1988))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\n\nDetermine the $n=8$ $17$-gonal number.\n", + "Output Answer": [ + "$833$" + ], + "Output Program": [ + "n = 8\nk = 17\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{4}$\n$x \\equiv 18 \\pmod{12}$\n$x \\equiv 15 \\pmod{7}$", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 4), (18, 12), (15, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 4), (18, 12), (15, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $-1025$ is divisible by $-5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1025 % -5 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1483)$.", + "Output Answer": [ + "$1482$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1483))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{336,-79\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 336, -79\nprint(math.gcd(*values))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $121x \\equiv 1 \\pmod{126}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(pow(121, -1, 126))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $2162^2043 \\pmod{2702}$.", + "Output Answer": [ + "$1322$" + ], + "Output Program": [ + "print(pow(2162, 2043, 2702))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38575)$.", + "Output Answer": [ + "$30840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38575))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIs the following number prime?\n2549", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2549))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{656}{61}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{61} \\left(\\sqrt{111305}-328\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(656/61)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{7192}{3351}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{24160417}-3596}{3351}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7192/3351)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{4331}{296}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{592} \\left(5 \\sqrt{764321}-4331\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4331/296)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79059 \\pmod{81}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(79059 % 81)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{449}{560}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1456001}-449}{1120}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(449/560)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{3998}{6599}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{47542802}-1999}{6599}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3998/6599)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $1245$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1245 % 48 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $477^m \\equiv 1 \\pmod{662}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(477, 662))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $1252^412 \\pmod{2789}$.", + "Output Answer": [ + "$2469$" + ], + "Output Program": [ + "print(pow(1252, 412, 2789))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 11 \\pmod{2}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 19), (11, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 19), (11, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 19), (11, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{44275}{4469}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2040163469}-44275}{8938}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(44275/4469)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFactor $98533$.", + "Output Answer": [ + "$98533^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(98533))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 19 \\pmod{19}$\n$x \\equiv 5 \\pmod{20}$", + "Output Answer": [ + "$665$" + ], + "Output Program": [ + "constraints = (2, 17), (19, 19), (5, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 17), (19, 19), (5, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 17), (19, 19), (5, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $51946$ is divisible by $38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(51946 % 38 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68721 \\pmod{29}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(68721 % 29)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nSimplify $606^698 \\pmod{936}$.", + "Output Answer": [ + "$792$" + ], + "Output Program": [ + "print(pow(606, 698, 936))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{1301}{2068}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18799097}-1301}{4136}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1301/2068)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1370x \\equiv 1 \\pmod{1679}$.", + "Output Answer": [ + "$614$" + ], + "Output Program": [ + "print(pow(1370, -1, 1679))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nDetermine whether $54180$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(54180 % -43 == 0)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $569^m \\equiv 1 \\pmod{767}$.", + "Output Answer": [ + "$174$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(569, 767))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4060)$.", + "Output Answer": [ + "$1344$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4060))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38397)$.", + "Output Answer": [ + "$25596$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38397))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $18617$.", + "Output Answer": [ + "$\\{3,5,6,12,20,21,23,24,27,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(18617):\n if len(roots) == 10: break\n if gcd(a, 18617) == 1 and is_primitive_root(a, 18617):\n roots.append(a)\nprint(roots)\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nIf $x = \\frac{638}{545}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{545} \\left(\\sqrt{398786}-319\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(638/545)')]]))\n" + ], + "split": "train" + }, + { + "Input": "Problem:\nConvert $0.18$ to base $2$.", + "Output Answer": [ + "$0.0010111000010100011111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.18\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $283x \\equiv 1 \\pmod{505}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(283, -1, 505))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-844$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-844 % -23 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6657}{9320}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{391765249}-6657}{18640}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6657/9320)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $797x \\equiv 1 \\pmod{1058}$.", + "Output Answer": [ + "$227$" + ], + "Output Program": [ + "print(pow(797, -1, 1058))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{38675}{13466}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2221088249}-38675}{26932}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(38675/13466)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $435^m \\equiv 1 \\pmod{446}$.", + "Output Answer": [ + "$111$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(435, 446))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $293x \\equiv 1 \\pmod{1332}$.", + "Output Answer": [ + "$641$" + ], + "Output Program": [ + "print(pow(293, -1, 1332))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n91151", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(91151))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $465x \\equiv 1 \\pmod{721}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "print(pow(465, -1, 721))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n12249", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12249))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1545^1448 \\pmod{2352}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(pow(1545, 1448, 2352))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{18518}{20973}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{525595810}-9259}{20973}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18518/20973)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-941,11,84\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -941, 11, 84\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 12 \\pmod{18}$", + "Output Answer": [ + "$156$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 13), (12, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 13), (12, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 13), (12, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1991^1191 \\pmod{2646}$.", + "Output Answer": [ + "$1763$" + ], + "Output Program": [ + "print(pow(1991, 1191, 2646))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $3418_9$ to base 10.", + "Output Answer": [ + "$2528$" + ], + "Output Program": [ + "n = '3418'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50325 \\pmod{53}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(50325 % 53)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1173^50 \\pmod{1875}$.", + "Output Answer": [ + "$1374$" + ], + "Output Program": [ + "print(pow(1173, 50, 1875))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(352)$.", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(352))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1099x \\equiv 1 \\pmod{1224}$.", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "print(pow(1099, -1, 1224))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $73^m \\equiv 1 \\pmod{133}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(73, 133))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n37003", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(37003))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{16}$\n$x \\equiv 12 \\pmod{5}$", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 16), (12, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 16), (12, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 16), (12, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.1426416_8$ to base 10.", + "Output Answer": [ + "$0.193$" + ], + "Output Program": [ + "n = '0.1426416'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $512^1417 \\pmod{533}$.", + "Output Answer": [ + "$525$" + ], + "Output Program": [ + "print(pow(512, 1417, 533))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2045x \\equiv 1 \\pmod{2219}$.", + "Output Answer": [ + "$1135$" + ], + "Output Program": [ + "print(pow(2045, -1, 2219))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{190,-490,681\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 190, -490, 681\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $894$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(894 % 22 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $721^2492 \\pmod{1381}$.", + "Output Answer": [ + "$1013$" + ], + "Output Program": [ + "print(pow(721, 2492, 1381))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1183^2283 \\pmod{2788}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(pow(1183, 2283, 2788))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $2010$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2010 % -44 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $233^m \\equiv 1 \\pmod{492}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(233, 492))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2237^630 \\pmod{2442}$.", + "Output Answer": [ + "$1849$" + ], + "Output Program": [ + "print(pow(2237, 630, 2442))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $17^m \\equiv 1 \\pmod{95}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(17, 95))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-129,3,-4\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -129, 3, -4\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1871^182 \\pmod{2541}$.", + "Output Answer": [ + "$2146$" + ], + "Output Program": [ + "print(pow(1871, 182, 2541))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16007)$.", + "Output Answer": [ + "$16006$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16007))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $217^m \\equiv 1 \\pmod{712}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(217, 712))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-341,806\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -341, 806\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $459$ to base $13$.", + "Output Answer": [ + "$294_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 459\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1940^2079 \\pmod{2899}$.", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "print(pow(1940, 2079, 2899))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2415^964 \\pmod{2780}$.", + "Output Answer": [ + "$2705$" + ], + "Output Program": [ + "print(pow(2415, 964, 2780))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1567x \\equiv 1 \\pmod{2154}$.", + "Output Answer": [ + "$433$" + ], + "Output Program": [ + "print(pow(1567, -1, 2154))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17832)$.", + "Output Answer": [ + "$5936$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17832))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $461^m \\equiv 1 \\pmod{911}$.", + "Output Answer": [ + "$182$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(461, 911))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 5 \\pmod{11}$\n$x \\equiv 11 \\pmod{7}$", + "Output Answer": [ + "$214$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 5), (5, 11), (11, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 5), (5, 11), (11, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 5), (5, 11), (11, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $514^1049 \\pmod{1773}$.", + "Output Answer": [ + "$1072$" + ], + "Output Program": [ + "print(pow(514, 1049, 1773))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $485x \\equiv 1 \\pmod{828}$.", + "Output Answer": [ + "$449$" + ], + "Output Program": [ + "print(pow(485, -1, 828))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $169^m \\equiv 1 \\pmod{328}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(169, 328))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $269x \\equiv 1 \\pmod{1330}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(269, -1, 1330))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1226$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1226 % -32 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46444 \\pmod{96}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "print(46444 % 96)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-123,600\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -123, 600\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $135^m \\equiv 1 \\pmod{994}$.", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(135, 994))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $869x \\equiv 1 \\pmod{1754}$.", + "Output Answer": [ + "$1425$" + ], + "Output Program": [ + "print(pow(869, -1, 1754))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n6337", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6337))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1701)$.", + "Output Answer": [ + "$972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1701))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{13}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 7 \\pmod{14}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$343$" + ], + "Output Program": [ + "constraints = (5, 13), (7, 7), (7, 14), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 13), (7, 7), (7, 14), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $558x \\equiv 1 \\pmod{917}$.", + "Output Answer": [ + "$682$" + ], + "Output Program": [ + "print(pow(558, -1, 917))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94245 \\pmod{23}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(94245 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 13 \\pmod{17}$", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "constraints = (19, 7), (13, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 7), (13, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 7), (13, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-879,104\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -879, 104\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-871,713,379\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -871, 713, 379\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $52^m \\equiv 1 \\pmod{717}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(52, 717))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $821^1393 \\pmod{2380}$.", + "Output Answer": [ + "$821$" + ], + "Output Program": [ + "print(pow(821, 1393, 2380))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $827x \\equiv 1 \\pmod{1556}$.", + "Output Answer": [ + "$651$" + ], + "Output Program": [ + "print(pow(827, -1, 1556))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 7 \\pmod{4}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 5), (7, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 5), (7, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 5), (7, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20477)$.", + "Output Answer": [ + "$20476$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20477))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13230)$.", + "Output Answer": [ + "$3024$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13230))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19975 \\pmod{48}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(19975 % 48)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.531021_9$ to base 10.", + "Output Answer": [ + "$0.594$" + ], + "Output Program": [ + "n = '0.531021'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1171x \\equiv 1 \\pmod{2093}$.", + "Output Answer": [ + "$1782$" + ], + "Output Program": [ + "print(pow(1171, -1, 2093))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n33857", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33857))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63733 \\pmod{85}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(63733 % 85)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $34471$.", + "Output Answer": [ + "$\\{6,12,13,26,33,34,38,54,58,60\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(34471):\n if len(roots) == 10: break\n if gcd(a, 34471) == 1 and is_primitive_root(a, 34471):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37491)$.", + "Output Answer": [ + "$24992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37491))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $771x \\equiv 1 \\pmod{1897}$.", + "Output Answer": [ + "$1555$" + ], + "Output Program": [ + "print(pow(771, -1, 1897))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 17 \\pmod{15}$", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (17, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 19), (17, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 19), (17, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $445^m \\equiv 1 \\pmod{798}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(445, 798))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $218^189 \\pmod{2606}$.", + "Output Answer": [ + "$1502$" + ], + "Output Program": [ + "print(pow(218, 189, 2606))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{14}$\n$x \\equiv 12 \\pmod{17}$", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "import math\n\nconstraints = (15, 14), (12, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 14), (12, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 14), (12, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $83x \\equiv 1 \\pmod{256}$.", + "Output Answer": [ + "$219$" + ], + "Output Program": [ + "print(pow(83, -1, 256))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-600$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-600 % 24 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{6}$\n$x \\equiv 3 \\pmod{5}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "constraints = (14, 6), (3, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 6), (3, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 6), (3, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{743}{972}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4331185}-743}{1944}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(743/972)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71499 \\pmod{36}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(71499 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $2088$ is divisible by $43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(2088 % 43 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{682,469\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 682, 469\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47114)$.", + "Output Answer": [ + "$23556$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47114))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2461}{2275}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{26759021}-2461}{4550}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2461/2275)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25671)$.", + "Output Answer": [ + "$16632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25671))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{14744}{20797}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{486861593}-7372}{20797}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14744/20797)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1505^1591 \\pmod{1580}$.", + "Output Answer": [ + "$625$" + ], + "Output Program": [ + "print(pow(1505, 1591, 1580))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1991$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1991 % -43 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16800)$.", + "Output Answer": [ + "$3840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16800))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-70$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-70 % -37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $242$ is divisible by $26$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(242 % 26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 1 \\pmod{6}$", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 17), (1, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 17), (1, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 17), (1, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{33}{433}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{866} \\left(\\sqrt{751045}-33\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33/433)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{7}$\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 9 \\pmod{9}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 7), (4, 2), (9, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 7), (4, 2), (9, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 7), (4, 2), (9, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58686 \\pmod{58}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(58686 % 58)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1$ is divisible by $1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1 % 1 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{276,-443,949\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 276, -443, 949\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $459^m \\equiv 1 \\pmod{860}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(459, 860))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.95$ to base $7$.", + "Output Answer": [ + "$0.6435644_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.95\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{283,-789\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 283, -789\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $101$ is divisible by $12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(101 % 12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9324)$.", + "Output Answer": [ + "$2592$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9324))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $365^m \\equiv 1 \\pmod{432}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(365, 432))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $437^12 \\pmod{2024}$.", + "Output Answer": [ + "$713$" + ], + "Output Program": [ + "print(pow(437, 12, 2024))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $97746$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 11^1\\cdot 1481^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(97746))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-464,726,31\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -464, 726, 31\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{107}{3442}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{47400905}-107}{6884}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(107/3442)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-24$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-24 % 32 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $103x \\equiv 1 \\pmod{702}$.", + "Output Answer": [ + "$259$" + ], + "Output Program": [ + "print(pow(103, -1, 702))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 12 \\pmod{3}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 11), (12, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (12, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 11), (12, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{34966}{25285}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{944986514}-17483}{25285}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34966/25285)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1373^996 \\pmod{2967}$.", + "Output Answer": [ + "$2419$" + ], + "Output Program": [ + "print(pow(1373, 996, 2967))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21469)$.", + "Output Answer": [ + "$18396$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21469))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2908 \\pmod{59}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(2908 % 59)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $347^m \\equiv 1 \\pmod{818}$.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(347, 818))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-3876$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3876 % 24 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{13}$\n$x \\equiv 14 \\pmod{5}$", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 13), (14, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 13), (14, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 13), (14, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $53690$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(53690 % -35 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1017^772 \\pmod{2242}$.", + "Output Answer": [ + "$897$" + ], + "Output Program": [ + "print(pow(1017, 772, 2242))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 13 \\pmod{19}$", + "Output Answer": [ + "$279$" + ], + "Output Program": [ + "constraints = (5, 2), (7, 17), (13, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 2), (7, 17), (13, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 2), (7, 17), (13, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35399)$.", + "Output Answer": [ + "$27936$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35399))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{14383}{7650}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{29 \\sqrt{524329}-14383}{15300}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14383/7650)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $104^m \\equiv 1 \\pmod{603}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(104, 603))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12791)$.", + "Output Answer": [ + "$12790$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12791))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5099 \\pmod{36}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(5099 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $670x \\equiv 1 \\pmod{867}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(pow(670, -1, 867))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66329 \\pmod{98}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(66329 % 98)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{8}$\n$x \\equiv 9 \\pmod{7}$\n$x \\equiv 2 \\pmod{19}$", + "Output Answer": [ + "$534$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 8), (9, 7), (2, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 8), (9, 7), (2, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 8), (9, 7), (2, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1954^93 \\pmod{2381}$.", + "Output Answer": [ + "$1720$" + ], + "Output Program": [ + "print(pow(1954, 93, 2381))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1390^855 \\pmod{1687}$.", + "Output Answer": [ + "$526$" + ], + "Output Program": [ + "print(pow(1390, 855, 1687))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $181x \\equiv 1 \\pmod{1755}$.", + "Output Answer": [ + "$766$" + ], + "Output Program": [ + "print(pow(181, -1, 1755))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{768,-960\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 768, -960\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n4833", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4833))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63144 \\pmod{13}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(63144 % 13)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $50^m \\equiv 1 \\pmod{177}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(50, 177))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{425,115\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 425, 115\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 14 \\pmod{17}$", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "constraints = (18, 10), (14, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 10), (14, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 10), (14, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6821)$.", + "Output Answer": [ + "$6444$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6821))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1405^1755 \\pmod{1557}$.", + "Output Answer": [ + "$829$" + ], + "Output Program": [ + "print(pow(1405, 1755, 1557))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1485^1337 \\pmod{2959}$.", + "Output Answer": [ + "$2651$" + ], + "Output Program": [ + "print(pow(1485, 1337, 2959))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{708,985\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 708, 985\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{587}{23}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{46} \\left(\\sqrt{346685}-587\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(587/23)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90894 \\pmod{49}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(90894 % 49)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14571)$.", + "Output Answer": [ + "$9708$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14571))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $892^1306 \\pmod{1857}$.", + "Output Answer": [ + "$151$" + ], + "Output Program": [ + "print(pow(892, 1306, 1857))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $591^1547 \\pmod{1222}$.", + "Output Answer": [ + "$1181$" + ], + "Output Program": [ + "print(pow(591, 1547, 1222))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $313^m \\equiv 1 \\pmod{584}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(313, 584))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $39971$.", + "Output Answer": [ + "$\\{2,7,8,10,18,21,24,26,28,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(39971):\n if len(roots) == 10: break\n if gcd(a, 39971) == 1 and is_primitive_root(a, 39971):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n42575", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(42575))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $534^144 \\pmod{732}$.", + "Output Answer": [ + "$192$" + ], + "Output Program": [ + "print(pow(534, 144, 732))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1345x \\equiv 1 \\pmod{1434}$.", + "Output Answer": [ + "$145$" + ], + "Output Program": [ + "print(pow(1345, -1, 1434))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-804,-16,395\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -804, -16, 395\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{15}$\n$x \\equiv 4 \\pmod{16}$", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "constraints = (15, 15), (4, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 15), (4, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 15), (4, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-712,555,-801\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -712, 555, -801\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6313}{3443}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{87270965}-6313}{6886}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6313/3443)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $871x \\equiv 1 \\pmod{1923}$.", + "Output Answer": [ + "$1753$" + ], + "Output Program": [ + "print(pow(871, -1, 1923))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8449)$.", + "Output Answer": [ + "$6720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8449))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2357^2 \\pmod{2397}$.", + "Output Answer": [ + "$1600$" + ], + "Output Program": [ + "print(pow(2357, 2, 2397))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35414)$.", + "Output Answer": [ + "$17706$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35414))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.753$ to base $33$.", + "Output Answer": [ + "$\\text{0.os0i}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.753\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7240)$.", + "Output Answer": [ + "$2880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7240))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $29^m \\equiv 1 \\pmod{637}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(29, 637))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90013 \\pmod{94}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(90013 % 94)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 5 \\pmod{19}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$1316$" + ], + "Output Program": [ + "constraints = (16, 10), (5, 19), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 10), (5, 19), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 10), (5, 19), (16, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5602}{5443}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1498874}-2801}{5443}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5602/5443)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9638}{17321}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{323239802}-4819}{17321}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9638/17321)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{19,594\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 19, 594\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{17367}{9502}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{662764705}-17367}{19004}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17367/9502)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{843,642\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 843, 642\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32779)$.", + "Output Answer": [ + "$32778$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32779))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-435,994\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -435, 994\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $26334$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(26334 % -33 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n6975", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6975))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 714 \\pmod{7}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(714 % 7)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1132^1927 \\pmod{2158}$.", + "Output Answer": [ + "$248$" + ], + "Output Program": [ + "print(pow(1132, 1927, 2158))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-62419$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-62419 % 37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $411^m \\equiv 1 \\pmod{763}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(411, 763))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $96^m \\equiv 1 \\pmod{733}$.", + "Output Answer": [ + "$732$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(96, 733))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $401^m \\equiv 1 \\pmod{488}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(401, 488))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{12221}{6852}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{337152457}-12221}{13704}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12221/6852)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4213)$.", + "Output Answer": [ + "$3820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4213))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34736 \\pmod{34}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(34736 % 34)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98606 \\pmod{62}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(98606 % 62)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $623x \\equiv 1 \\pmod{1363}$.", + "Output Answer": [ + "$897$" + ], + "Output Program": [ + "print(pow(623, -1, 1363))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{248,333,934\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 248, 333, 934\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n64019", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64019))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $92546$.", + "Output Answer": [ + "$2^1\\cdot 46273^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(92546))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97899 \\pmod{2}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(97899 % 2)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9491}{12190}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{684463481}-9491}{24380}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9491/12190)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $84$ is divisible by $28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(84 % 28 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77430 \\pmod{55}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(77430 % 55)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $311x \\equiv 1 \\pmod{336}$.", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "print(pow(311, -1, 336))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{803,299\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 803, 299\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $186^m \\equiv 1 \\pmod{907}$.", + "Output Answer": [ + "$906$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(186, 907))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $52936$.", + "Output Answer": [ + "$2^3\\cdot 13^1\\cdot 509^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(52936))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $35^m \\equiv 1 \\pmod{386}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(35, 386))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-567,-740\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -567, -740\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39679)$.", + "Output Answer": [ + "$39678$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39679))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44228)$.", + "Output Answer": [ + "$22112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44228))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $35_{30}$ to base 10.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "n = '35'.strip('.')\nbase = 30\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8764}{9089}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{101811845}-4382}{9089}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8764/9089)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $161x \\equiv 1 \\pmod{1230}$.", + "Output Answer": [ + "$191$" + ], + "Output Program": [ + "print(pow(161, -1, 1230))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{77}{507}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{41365}-77}{1014}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(77/507)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{7148}{4237}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{30725645}-3574}{4237}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7148/4237)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53974$.", + "Output Answer": [ + "$\\{5,7,11,15,19,21,23,29,33,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53974):\n if len(roots) == 10: break\n if gcd(a, 53974) == 1 and is_primitive_root(a, 53974):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-15576$ is divisible by $-24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-15576 % -24 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{10}$\n$x \\equiv 7 \\pmod{12}$\n$x \\equiv 19 \\pmod{16}$", + "Output Answer": [ + "$67$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 10), (7, 12), (19, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 10), (7, 12), (19, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69691 \\pmod{53}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(69691 % 53)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $58493$.", + "Output Answer": [ + "$29^1\\cdot 2017^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(58493))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $204^m \\equiv 1 \\pmod{659}$.", + "Output Answer": [ + "$329$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(204, 659))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{91,-387,-750\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 91, -387, -750\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5651}{10105}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{440377901}-5651}{20210}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5651/10105)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6670)$.", + "Output Answer": [ + "$2464$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6670))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1199^2179 \\pmod{2683}$.", + "Output Answer": [ + "$1510$" + ], + "Output Program": [ + "print(pow(1199, 2179, 2683))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $14474$.", + "Output Answer": [ + "$\\{5,7,11,15,21,23,33,37,47,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(14474):\n if len(roots) == 10: break\n if gcd(a, 14474) == 1 and is_primitive_root(a, 14474):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2232^43 \\pmod{2652}$.", + "Output Answer": [ + "$2544$" + ], + "Output Program": [ + "print(pow(2232, 43, 2652))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $190$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(190 % 5 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 4 \\pmod{7}$", + "Output Answer": [ + "$200$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 8), (10, 5), (4, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 8), (10, 5), (4, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 8), (10, 5), (4, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{967,-309,188\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 967, -309, 188\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{110,-871,804\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 110, -871, 804\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-27375$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-27375 % 25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-336,-378\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -336, -378\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{780,159\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 780, 159\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{309,-865\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 309, -865\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $988^517 \\pmod{2854}$.", + "Output Answer": [ + "$190$" + ], + "Output Program": [ + "print(pow(988, 517, 2854))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1094)$.", + "Output Answer": [ + "$546$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1094))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $36^1369 \\pmod{2474}$.", + "Output Answer": [ + "$1024$" + ], + "Output Program": [ + "print(pow(36, 1369, 2474))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1848_9$ to base 10.", + "Output Answer": [ + "$1421$" + ], + "Output Program": [ + "n = '1848'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $50618$.", + "Output Answer": [ + "$\\{13,29,67,71,87,89,91,93,103,113\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(50618):\n if len(roots) == 10: break\n if gcd(a, 50618) == 1 and is_primitive_root(a, 50618):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4108)$.", + "Output Answer": [ + "$1872$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4108))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{175}{258}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{516} \\left(\\sqrt{296881}-175\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(175/258)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53819$.", + "Output Answer": [ + "$\\{2,6,8,10,14,17,18,19,22,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53819):\n if len(roots) == 10: break\n if gcd(a, 53819) == 1 and is_primitive_root(a, 53819):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2213_9$ to base 10.", + "Output Answer": [ + "$1632$" + ], + "Output Program": [ + "n = '2213'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2890}{267}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{267} \\left(\\sqrt{2159314}-1445\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2890/267)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1938$ is divisible by $45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1938 % 45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1594^749 \\pmod{1938}$.", + "Output Answer": [ + "$574$" + ], + "Output Program": [ + "print(pow(1594, 749, 1938))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $496$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(496 % -15 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $15938$ is divisible by $26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(15938 % 26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2640}{9059}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{83807881}-1320}{9059}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2640/9059)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-331$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-331 % -23 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4758)$.", + "Output Answer": [ + "$1440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4758))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $283^m \\equiv 1 \\pmod{320}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(283, 320))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 1 \\pmod{10}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 1 \\pmod{17}$", + "Output Answer": [ + "$511$" + ], + "Output Program": [ + "constraints = (0, 7), (1, 10), (7, 7), (1, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (1, 10), (7, 7), (1, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $575^m \\equiv 1 \\pmod{684}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(575, 684))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{113}{430}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{860} \\left(\\sqrt{752369}-113\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(113/430)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 2 \\pmod{7}$", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 9), (3, 4), (2, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 9), (3, 4), (2, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 9), (3, 4), (2, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{19759}{46150}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8909708081}-19759}{92300}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19759/46150)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7234)$.", + "Output Answer": [ + "$3616$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7234))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $787x \\equiv 1 \\pmod{1684}$.", + "Output Answer": [ + "$199$" + ], + "Output Program": [ + "print(pow(787, -1, 1684))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-753,150\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -753, 150\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $413^m \\equiv 1 \\pmod{647}$.", + "Output Answer": [ + "$646$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(413, 647))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51395 \\pmod{15}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(51395 % 15)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{9}$\n$x \\equiv 11 \\pmod{14}$", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 9), (11, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 9), (11, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 9), (11, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-5328$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5328 % 18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $691^m \\equiv 1 \\pmod{919}$.", + "Output Answer": [ + "$918$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(691, 919))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $218x \\equiv 1 \\pmod{361}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(218, -1, 361))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-57120$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-57120 % -42 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n10979", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10979))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-6460$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6460 % -38 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9281)$.", + "Output Answer": [ + "$9280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9281))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22415 \\pmod{56}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(22415 % 56)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3256}{2487}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8835553}-1628}{2487}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3256/2487)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{18}$\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 16 \\pmod{4}$", + "Output Answer": [ + "$108$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 18), (4, 13), (16, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 18), (4, 13), (16, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $51586$.", + "Output Answer": [ + "$\\{3,5,7,19,23,27,29,33,45,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(51586):\n if len(roots) == 10: break\n if gcd(a, 51586) == 1 and is_primitive_root(a, 51586):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31044)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31044))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3257)$.", + "Output Answer": [ + "$3256$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3257))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{10}$\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 10), (6, 19), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 10), (6, 19), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-316,-164\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -316, -164\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29837$.", + "Output Answer": [ + "$\\{2,3,5,7,8,12,13,18,20,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29837):\n if len(roots) == 10: break\n if gcd(a, 29837) == 1 and is_primitive_root(a, 29837):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-7310$ is divisible by $-20$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-7310 % -20 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.297$ to base $5$.", + "Output Answer": [ + "$0.122030303_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.297\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2147}{6816}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{190441033}-2147}{13632}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2147/6816)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1633x \\equiv 1 \\pmod{1842}$.", + "Output Answer": [ + "$661$" + ], + "Output Program": [ + "print(pow(1633, -1, 1842))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{946,564\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 946, 564\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31530)$.", + "Output Answer": [ + "$8400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31530))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.01320132_7$ to base 10.", + "Output Answer": [ + "$0.03$" + ], + "Output Program": [ + "n = '0.01320132'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2069^114 \\pmod{2769}$.", + "Output Answer": [ + "$571$" + ], + "Output Program": [ + "print(pow(2069, 114, 2769))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $121^m \\equiv 1 \\pmod{908}$.", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(121, 908))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2364)$.", + "Output Answer": [ + "$784$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2364))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21480)$.", + "Output Answer": [ + "$5696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21480))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $776x \\equiv 1 \\pmod{2341}$.", + "Output Answer": [ + "$540$" + ], + "Output Program": [ + "print(pow(776, -1, 2341))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84334 \\pmod{92}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(84334 % 92)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48965 \\pmod{45}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(48965 % 45)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-25259$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-25259 % 29 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-253,663\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -253, 663\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $685x \\equiv 1 \\pmod{1106}$.", + "Output Answer": [ + "$951$" + ], + "Output Program": [ + "print(pow(685, -1, 1106))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $701^m \\equiv 1 \\pmod{772}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(701, 772))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58739 \\pmod{35}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(58739 % 35)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1592^175 \\pmod{2504}$.", + "Output Answer": [ + "$1296$" + ], + "Output Program": [ + "print(pow(1592, 175, 2504))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $329x \\equiv 1 \\pmod{734}$.", + "Output Answer": [ + "$705$" + ], + "Output Program": [ + "print(pow(329, -1, 734))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-829,-380\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -829, -380\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $2486$ is divisible by $22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2486 % 22 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{27067}{22145}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2694226589}-27067}{44290}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27067/22145)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,4,-3\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 4, -3\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{10}$\n$x \\equiv 1 \\pmod{7}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 10), (1, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 10), (1, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 10), (1, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{6}$\n$x \\equiv 9 \\pmod{19}$\n$x \\equiv 1 \\pmod{4}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$1301$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 6), (9, 19), (1, 4), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 6), (9, 19), (1, 4), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n4513", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(4513))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4442)$.", + "Output Answer": [ + "$2220$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4442))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25332)$.", + "Output Answer": [ + "$8440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25332))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2041}{25918}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2691136577}-2041}{51836}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2041/25918)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1519x \\equiv 1 \\pmod{1790}$.", + "Output Answer": [ + "$1539$" + ], + "Output Program": [ + "print(pow(1519, -1, 1790))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36707 \\pmod{70}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(36707 % 70)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{101,132,-495\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 101, 132, -495\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{725,259,-319\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 725, 259, -319\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n54789", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54789))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2417^155 \\pmod{2639}$.", + "Output Answer": [ + "$1208$" + ], + "Output Program": [ + "print(pow(2417, 155, 2639))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17620)$.", + "Output Answer": [ + "$7040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17620))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 20 \\pmod{10}$", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 11), (20, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 11), (20, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 11), (20, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2307^2362 \\pmod{2520}$.", + "Output Answer": [ + "$1089$" + ], + "Output Program": [ + "print(pow(2307, 2362, 2520))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45612)$.", + "Output Answer": [ + "$12960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45612))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $433x \\equiv 1 \\pmod{826}$.", + "Output Answer": [ + "$475$" + ], + "Output Program": [ + "print(pow(433, -1, 826))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $13464$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(13464 % 33 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $667^m \\equiv 1 \\pmod{672}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(667, 672))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10946}{5063}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{55587698}-5473}{5063}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10946/5063)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18037)$.", + "Output Answer": [ + "$16960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18037))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $128x \\equiv 1 \\pmod{1945}$.", + "Output Answer": [ + "$1322$" + ], + "Output Program": [ + "print(pow(128, -1, 1945))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $599^m \\equiv 1 \\pmod{935}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(599, 935))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $390$ is divisible by $16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(390 % 16 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 11 \\pmod{10}$", + "Output Answer": [ + "$121$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 13), (11, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 13), (11, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 13), (11, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-67431$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-67431 % -39 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{768,131\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 768, 131\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2809}{3793}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{65437877}-2809}{7586}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2809/3793)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $78198$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 13033^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(78198))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{8}$\n$x \\equiv 8 \\pmod{7}$", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "constraints = (5, 8), (8, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 8), (8, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 8), (8, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $770^948 \\pmod{2877}$.", + "Output Answer": [ + "$1183$" + ], + "Output Program": [ + "print(pow(770, 948, 2877))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "constraints = (20, 5), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 5), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 5), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{11270}{20821}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{465267266}-5635}{20821}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11270/20821)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $453x \\equiv 1 \\pmod{464}$.", + "Output Answer": [ + "$253$" + ], + "Output Program": [ + "print(pow(453, -1, 464))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $462^2315 \\pmod{3000}$.", + "Output Answer": [ + "$1368$" + ], + "Output Program": [ + "print(pow(462, 2315, 3000))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17870 \\pmod{84}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(17870 % 84)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $424_{24}$ to base 10.", + "Output Answer": [ + "$2356$" + ], + "Output Program": [ + "n = '424'.strip('.')\nbase = 24\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $70960$.", + "Output Answer": [ + "$2^4\\cdot 5^1\\cdot 887^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(70960))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29311 \\pmod{26}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(29311 % 26)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33621)$.", + "Output Answer": [ + "$19200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33621))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $19237$.", + "Output Answer": [ + "$\\{2,14,17,20,22,24,26,32,42,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(19237):\n if len(roots) == 10: break\n if gcd(a, 19237) == 1 and is_primitive_root(a, 19237):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{832,399,801\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 832, 399, 801\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-572,820,547\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -572, 820, 547\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $4550$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4550 % 14 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1269^1613 \\pmod{2306}$.", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "print(pow(1269, 1613, 2306))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64058 \\pmod{86}$.", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "print(64058 % 86)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,1,3,-2\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 1, 3, -2\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $10626$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 7^1\\cdot 11^1\\cdot 23^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(10626))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{107,-65,-808\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 107, -65, -808\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58042 \\pmod{21}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(58042 % 21)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-218$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-218 % -9 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1624^49 \\pmod{1820}$.", + "Output Answer": [ + "$1624$" + ], + "Output Program": [ + "print(pow(1624, 49, 1820))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $887x \\equiv 1 \\pmod{2010}$.", + "Output Answer": [ + "$1763$" + ], + "Output Program": [ + "print(pow(887, -1, 2010))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 18 \\pmod{12}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "constraints = (12, 18), (18, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (18, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9093}{3326}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{126931753}-9093}{6652}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9093/3326)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2137x \\equiv 1 \\pmod{2181}$.", + "Output Answer": [ + "$1834$" + ], + "Output Program": [ + "print(pow(2137, -1, 2181))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $230101_4$ to base 10.", + "Output Answer": [ + "$2833$" + ], + "Output Program": [ + "n = '230101'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2128}{7137}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{52068865}-1064}{7137}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2128/7137)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n16223", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16223))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.1222101020022_3$ to base 10.", + "Output Answer": [ + "$0.659$" + ], + "Output Program": [ + "n = '0.1222101020022'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n63387", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63387))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{63,-460\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 63, -460\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n68791", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(68791))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 18 \\pmod{7}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$8285$" + ], + "Output Program": [ + "constraints = (10, 5), (6, 17), (18, 7), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (10, 5), (6, 17), (18, 7), (1, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (6, 17), (18, 7), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2041^2037 \\pmod{2275}$.", + "Output Answer": [ + "$806$" + ], + "Output Program": [ + "print(pow(2041, 2037, 2275))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n21163", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21163))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $84843$.", + "Output Answer": [ + "$3^2\\cdot 11^1\\cdot 857^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(84843))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $89^m \\equiv 1 \\pmod{205}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(89, 205))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{10}$\n$x \\equiv 14 \\pmod{3}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 10), (14, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 10), (14, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 10), (14, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5747}{397}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{794} \\left(\\sqrt{33658445}-5747\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5747/397)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25405)$.", + "Output Answer": [ + "$20320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25405))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19867)$.", + "Output Answer": [ + "$19866$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19867))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35325)$.", + "Output Answer": [ + "$18720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35325))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $78996$.", + "Output Answer": [ + "$2^2\\cdot 3^1\\cdot 29^1\\cdot 227^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(78996))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1735^100 \\pmod{2970}$.", + "Output Answer": [ + "$925$" + ], + "Output Program": [ + "print(pow(1735, 100, 2970))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85473 \\pmod{51}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(85473 % 51)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n2113", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2113))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{155,490\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 155, 490\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $136x \\equiv 1 \\pmod{1333}$.", + "Output Answer": [ + "$1284$" + ], + "Output Program": [ + "print(pow(136, -1, 1333))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1247x \\equiv 1 \\pmod{1297}$.", + "Output Answer": [ + "$856$" + ], + "Output Program": [ + "print(pow(1247, -1, 1297))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.1010110022102_3$ to base 10.", + "Output Answer": [ + "$0.376$" + ], + "Output Program": [ + "n = '0.1010110022102'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{7503}{14692}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{919714465}-7503}{29384}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7503/14692)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $99^987 \\pmod{1113}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(pow(99, 987, 1113))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1884$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1884 % -38 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-938,890\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -938, 890\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1012)$.", + "Output Answer": [ + "$440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1012))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $797x \\equiv 1 \\pmod{2406}$.", + "Output Answer": [ + "$1283$" + ], + "Output Program": [ + "print(pow(797, -1, 2406))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-983$ is divisible by $45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-983 % 45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5156)$.", + "Output Answer": [ + "$2576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5156))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-10241$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10241 % -19 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1746^1054 \\pmod{1915}$.", + "Output Answer": [ + "$671$" + ], + "Output Program": [ + "print(pow(1746, 1054, 1915))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{951,395,738\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 951, 395, 738\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.909$ to base $11$.", + "Output Answer": [ + "$\\text{0.9aa974}_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.909\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-982,-82,-396\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -982, -82, -396\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{163,-7\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 163, -7\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $44651$.", + "Output Answer": [ + "$\\{2,8,10,14,18,19,22,23,24,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(44651):\n if len(roots) == 10: break\n if gcd(a, 44651) == 1 and is_primitive_root(a, 44651):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1990^2006 \\pmod{2562}$.", + "Output Answer": [ + "$1516$" + ], + "Output Program": [ + "print(pow(1990, 2006, 2562))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-4477$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4477 % -37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $16x \\equiv 1 \\pmod{73}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(pow(16, -1, 73))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{6}$\n$x \\equiv 5 \\pmod{8}$", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 6), (5, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 6), (5, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{271}{5373}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{115549957}-271}{10746}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(271/5373)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $553x \\equiv 1 \\pmod{1131}$.", + "Output Answer": [ + "$769$" + ], + "Output Program": [ + "print(pow(553, -1, 1131))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{331,-369,988\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 331, -369, 988\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n26183", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26183))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n10461", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10461))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.479$ to base $2$.", + "Output Answer": [ + "$0.011110101001111111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.479\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2081x \\equiv 1 \\pmod{2112}$.", + "Output Answer": [ + "$545$" + ], + "Output Program": [ + "print(pow(2081, -1, 2112))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{18}$\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 3 \\pmod{13}$", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 18), (4, 17), (3, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 18), (4, 17), (3, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 18), (4, 17), (3, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $181$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(181 % -17 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 15 \\pmod{20}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "constraints = (20, 5), (3, 8), (3, 8), (15, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 5), (3, 8), (3, 8), (15, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1629x \\equiv 1 \\pmod{1982}$.", + "Output Answer": [ + "$1297$" + ], + "Output Program": [ + "print(pow(1629, -1, 1982))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89851 \\pmod{54}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(89851 % 54)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2137}{3160}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{44509169}-2137}{6320}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2137/3160)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{356,123,-196\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 356, 123, -196\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2721$ to base $22$.", + "Output Answer": [ + "$\\text{5df}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2721\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $883x \\equiv 1 \\pmod{2142}$.", + "Output Answer": [ + "$883$" + ], + "Output Program": [ + "print(pow(883, -1, 2142))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{16}$\n$x \\equiv 5 \\pmod{18}$\n$x \\equiv 7 \\pmod{10}$", + "Output Answer": [ + "$347$" + ], + "Output Program": [ + "constraints = (11, 16), (5, 18), (7, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 16), (5, 18), (7, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $205^m \\equiv 1 \\pmod{618}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(205, 618))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2552$ to base $19$.", + "Output Answer": [ + "$716_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2552\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $635x \\equiv 1 \\pmod{716}$.", + "Output Answer": [ + "$495$" + ], + "Output Program": [ + "print(pow(635, -1, 716))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{769}{16748}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1122573377}-769}{33496}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(769/16748)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{26093}{9483}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1040553805}-26093}{18966}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26093/9483)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42837)$.", + "Output Answer": [ + "$28080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42837))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $805^m \\equiv 1 \\pmod{808}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(805, 808))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26296)$.", + "Output Answer": [ + "$12384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26296))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2620}{1293}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3387949}-1310}{1293}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2620/1293)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{522,601,-759\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 522, 601, -759\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $539^m \\equiv 1 \\pmod{746}$.", + "Output Answer": [ + "$372$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(539, 746))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $661x \\equiv 1 \\pmod{2288}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(pow(661, -1, 2288))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8086)$.", + "Output Answer": [ + "$3720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8086))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-392,349\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -392, 349\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43357)$.", + "Output Answer": [ + "$42940$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43357))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $736^m \\equiv 1 \\pmod{747}$.", + "Output Answer": [ + "$246$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(736, 747))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10064}{3691}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{38944505}-5032}{3691}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10064/3691)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53573 \\pmod{82}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(53573 % 82)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43177 \\pmod{36}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(43177 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $178^2265 \\pmod{2587}$.", + "Output Answer": [ + "$703$" + ], + "Output Program": [ + "print(pow(178, 2265, 2587))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{776}{261}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{261} \\left(\\sqrt{218665}-388\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(776/261)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{561,-508\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 561, -508\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1178x \\equiv 1 \\pmod{1251}$.", + "Output Answer": [ + "$377$" + ], + "Output Program": [ + "print(pow(1178, -1, 1251))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 6 \\pmod{19}$", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "constraints = (13, 11), (6, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (6, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 11), (6, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $26^m \\equiv 1 \\pmod{167}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(26, 167))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $715^m \\equiv 1 \\pmod{866}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(715, 866))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $31^m \\equiv 1 \\pmod{488}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(31, 488))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34352 \\pmod{4}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(34352 % 4)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $55^m \\equiv 1 \\pmod{228}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(55, 228))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $15120$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(15120 % -27 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23913 \\pmod{31}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(23913 % 31)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n31273", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31273))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $267^1617 \\pmod{842}$.", + "Output Answer": [ + "$151$" + ], + "Output Program": [ + "print(pow(267, 1617, 842))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 5), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 5), (16, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 5), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93966 \\pmod{98}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "print(93966 % 98)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1139}{162}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{324} \\left(\\sqrt{1402297}-1139\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1139/162)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{68,-107\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 68, -107\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $134^m \\equiv 1 \\pmod{591}$.", + "Output Answer": [ + "$98$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(134, 591))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n25659", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(25659))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{861,878,-98\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 861, 878, -98\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{750,-97,-720\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 750, -97, -720\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $139x \\equiv 1 \\pmod{949}$.", + "Output Answer": [ + "$198$" + ], + "Output Program": [ + "print(pow(139, -1, 949))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5749}{3335}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{77539901}-5749}{6670}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5749/3335)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $80226$.", + "Output Answer": [ + "$2^1\\cdot 3^2\\cdot 4457^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(80226))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{15332}{11911}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{200639477}-7666}{11911}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15332/11911)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $677x \\equiv 1 \\pmod{1115}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(pow(677, -1, 1115))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $283^611 \\pmod{2345}$.", + "Output Answer": [ + "$1027$" + ], + "Output Program": [ + "print(pow(283, 611, 2345))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89728 \\pmod{32}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(89728 % 32)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n9491", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9491))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $97^m \\equiv 1 \\pmod{480}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(97, 480))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78886 \\pmod{42}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(78886 % 42)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15819)$.", + "Output Answer": [ + "$10544$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15819))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10760)$.", + "Output Answer": [ + "$4288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10760))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2406^1084 \\pmod{2495}$.", + "Output Answer": [ + "$1101$" + ], + "Output Program": [ + "print(pow(2406, 1084, 2495))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $153^m \\equiv 1 \\pmod{982}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(153, 982))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{15}$\n$x \\equiv 11 \\pmod{2}$\n$x \\equiv 7 \\pmod{19}$\n$x \\equiv 5 \\pmod{16}$", + "Output Answer": [ + "$3541$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 15), (11, 2), (7, 19), (5, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 15), (11, 2), (7, 19), (5, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $20674$.", + "Output Answer": [ + "$\\{3,5,7,11,13,23,27,37,45,47\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(20674):\n if len(roots) == 10: break\n if gcd(a, 20674) == 1 and is_primitive_root(a, 20674):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56218 \\pmod{100}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(56218 % 100)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $763$ to base $23$.", + "Output Answer": [ + "$\\text{1a4}_{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 763\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1380_{11}$ to base 10.", + "Output Answer": [ + "$1782$" + ], + "Output Program": [ + "n = '1380'.strip('.')\nbase = 11\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $190$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(190 % 8 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69883 \\pmod{74}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(69883 % 74)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3096}{2873}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10650433}-1548}{2873}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3096/2873)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $598^m \\equiv 1 \\pmod{899}$.", + "Output Answer": [ + "$420$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(598, 899))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62125 \\pmod{38}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(62125 % 38)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1221x \\equiv 1 \\pmod{1391}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "print(pow(1221, -1, 1391))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92541 \\pmod{90}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(92541 % 90)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $367^m \\equiv 1 \\pmod{724}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(367, 724))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.296$ to base $29$.", + "Output Answer": [ + "$\\text{0.8gr4}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.296\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5480 \\pmod{41}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(5480 % 41)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24032 \\pmod{64}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(24032 % 64)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $177^2053 \\pmod{866}$.", + "Output Answer": [ + "$177$" + ], + "Output Program": [ + "print(pow(177, 2053, 866))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1583^2390 \\pmod{2549}$.", + "Output Answer": [ + "$1950$" + ], + "Output Program": [ + "print(pow(1583, 2390, 2549))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-921,783,-781\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -921, 783, -781\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $347^m \\equiv 1 \\pmod{678}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(347, 678))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{136}{47}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{47} \\left(\\sqrt{6833}-68\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(136/47)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71650 \\pmod{71}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(71650 % 71)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $383x \\equiv 1 \\pmod{2456}$.", + "Output Answer": [ + "$1943$" + ], + "Output Program": [ + "print(pow(383, -1, 2456))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{112,580,241\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 112, 580, 241\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $711^2129 \\pmod{2671}$.", + "Output Answer": [ + "$1081$" + ], + "Output Program": [ + "print(pow(711, 2129, 2671))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5885)$.", + "Output Answer": [ + "$4240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5885))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3108}{1565}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4864141}-1554}{1565}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3108/1565)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 1 \\pmod{11}$", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "constraints = (10, 5), (1, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (1, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 5), (1, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $30x \\equiv 1 \\pmod{763}$.", + "Output Answer": [ + "$585$" + ], + "Output Program": [ + "print(pow(30, -1, 763))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 11 \\pmod{15}$", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "constraints = (12, 13), (11, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 13), (11, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 13), (11, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $72_{29}$ to base 10.", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "n = '72'.strip('.')\nbase = 29\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $32194$.", + "Output Answer": [ + "$\\{3,5,21,23,27,29,33,35,37,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(32194):\n if len(roots) == 10: break\n if gcd(a, 32194) == 1 and is_primitive_root(a, 32194):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{383,127,26\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 383, 127, 26\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 6 \\pmod{16}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$1350$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 5), (6, 16), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 5), (6, 16), (1, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 5), (6, 16), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $121211_3$ to base 10.", + "Output Answer": [ + "$454$" + ], + "Output Program": [ + "n = '121211'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56895 \\pmod{43}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(56895 % 43)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(725)$.", + "Output Answer": [ + "$560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(725))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{14445}{7223}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{417344941}-14445}{14446}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14445/7223)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2904}{5311}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1212601}-1452}{5311}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2904/5311)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{55,-158,-25\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 55, -158, -25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26024)$.", + "Output Answer": [ + "$13008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26024))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $631x \\equiv 1 \\pmod{2011}$.", + "Output Answer": [ + "$1619$" + ], + "Output Program": [ + "print(pow(631, -1, 2011))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n3253", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(3253))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{212,-658\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 212, -658\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-2408$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2408 % -8 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $477^697 \\pmod{1595}$.", + "Output Answer": [ + "$1512$" + ], + "Output Program": [ + "print(pow(477, 697, 1595))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2479^2210 \\pmod{2755}$.", + "Output Answer": [ + "$1251$" + ], + "Output Program": [ + "print(pow(2479, 2210, 2755))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $37361$.", + "Output Answer": [ + "$\\{3,6,17,21,24,27,30,33,34,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(37361):\n if len(roots) == 10: break\n if gcd(a, 37361) == 1 and is_primitive_root(a, 37361):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-24998$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-24998 % 29 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.53041531_6$ to base 10.", + "Output Answer": [ + "$0.92$" + ], + "Output Program": [ + "n = '0.53041531'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{376}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 376))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 13 \\pmod{4}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 11), (13, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 11), (13, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 11), (13, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $611x \\equiv 1 \\pmod{683}$.", + "Output Answer": [ + "$332$" + ], + "Output Program": [ + "print(pow(611, -1, 683))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2993}{585}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10326949}-2993}{1170}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2993/585)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{18}$\n$x \\equiv 8 \\pmod{20}$", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 18), (8, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 18), (8, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{58,-233\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 58, -233\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3396}{17771}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{318691645}-1698}{17771}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3396/17771)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $432x \\equiv 1 \\pmod{775}$.", + "Output Answer": [ + "$418$" + ], + "Output Program": [ + "print(pow(432, -1, 775))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 5 \\pmod{10}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 2), (5, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 2), (5, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $63^m \\equiv 1 \\pmod{916}$.", + "Output Answer": [ + "$228$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(63, 916))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48290 \\pmod{27}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(48290 % 27)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21971 \\pmod{83}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(21971 % 83)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $740^1584 \\pmod{978}$.", + "Output Answer": [ + "$868$" + ], + "Output Program": [ + "print(pow(740, 1584, 978))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1089^2500 \\pmod{1833}$.", + "Output Answer": [ + "$1602$" + ], + "Output Program": [ + "print(pow(1089, 2500, 1833))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1789x \\equiv 1 \\pmod{2004}$.", + "Output Answer": [ + "$1249$" + ], + "Output Program": [ + "print(pow(1789, -1, 2004))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62927 \\pmod{86}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(62927 % 86)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67592 \\pmod{36}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(67592 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $468x \\equiv 1 \\pmod{665}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(pow(468, -1, 665))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16569 \\pmod{8}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(16569 % 8)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{338,283\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 338, 283\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $249^m \\equiv 1 \\pmod{293}$.", + "Output Answer": [ + "$292$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(249, 293))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24410)$.", + "Output Answer": [ + "$9760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24410))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-114,998\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -114, 998\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{28479}{9065}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1139750341}-28479}{18130}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(28479/9065)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1180^1957 \\pmod{2164}$.", + "Output Answer": [ + "$1820$" + ], + "Output Program": [ + "print(pow(1180, 1957, 2164))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-32509$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-32509 % 29 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-102$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-102 % 6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{20}$\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 12 \\pmod{3}$", + "Output Answer": [ + "$177$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 20), (6, 19), (12, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 20), (6, 19), (12, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 20), (6, 19), (12, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3522)$.", + "Output Answer": [ + "$1172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3522))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $2280$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2280 % 20 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{15}$\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 20 \\pmod{2}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "constraints = (2, 15), (13, 19), (20, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 15), (13, 19), (20, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 15), (13, 19), (20, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{21047}{8779}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{751259573}-21047}{17558}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21047/8779)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $263x \\equiv 1 \\pmod{311}$.", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "print(pow(263, -1, 311))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2454}{4151}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18736330}-1227}{4151}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2454/4151)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76165 \\pmod{56}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(76165 % 56)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.356$ to base $26$.", + "Output Answer": [ + "$\\text{0.96h1}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.356\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{218,-786,389\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 218, -786, 389\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $889x \\equiv 1 \\pmod{1352}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(889, -1, 1352))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $205x \\equiv 1 \\pmod{278}$.", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "print(pow(205, -1, 278))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49143)$.", + "Output Answer": [ + "$32760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49143))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1830$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1830 % 39 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $33^m \\equiv 1 \\pmod{232}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(33, 232))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{2}$\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 11 \\pmod{18}$", + "Output Answer": [ + "$281$" + ], + "Output Program": [ + "constraints = (11, 2), (15, 19), (11, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 2), (15, 19), (11, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{16575}{224}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{448} \\left(\\sqrt{274931329}-16575\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16575/224)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-775,127,780\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -775, 127, 780\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9107}{204}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{408} \\left(\\sqrt{83103913}-9107\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9107/204)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2031$ to base $8$.", + "Output Answer": [ + "$3757_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2031\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1541x \\equiv 1 \\pmod{1754}$.", + "Output Answer": [ + "$807$" + ], + "Output Program": [ + "print(pow(1541, -1, 1754))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{808,-307\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 808, -307\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72637 \\pmod{92}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(72637 % 92)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $67540$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(67540 % -44 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55189 \\pmod{23}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(55189 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1766$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1766 % -40 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32754)$.", + "Output Answer": [ + "$10608$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32754))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $7595$ is divisible by $31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7595 % 31 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $5656_8$ to base 10.", + "Output Answer": [ + "$2990$" + ], + "Output Program": [ + "n = '5656'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1945}{3412}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{297929}-1945}{6824}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1945/3412)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1299^1737 \\pmod{1605}$.", + "Output Answer": [ + "$459$" + ], + "Output Program": [ + "print(pow(1299, 1737, 1605))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{5}$\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 14 \\pmod{6}$", + "Output Answer": [ + "$410$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 5), (2, 17), (14, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 5), (2, 17), (14, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 5), (2, 17), (14, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $159^m \\equiv 1 \\pmod{805}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(159, 805))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{26604}{19003}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{538057213}-13302}{19003}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26604/19003)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $186^1298 \\pmod{853}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(pow(186, 1298, 853))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $9540$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9540 % 18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50088 \\pmod{63}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(50088 % 63)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{13959}{24328}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2562260017}-13959}{48656}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13959/24328)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2859}{724}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10270585}-2859}{1448}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2859/724)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $2266$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2266 % -11 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 8 \\pmod{7}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "constraints = (15, 5), (3, 4), (8, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 5), (3, 4), (8, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 5), (3, 4), (8, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98799 \\pmod{18}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(98799 % 18)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8083}{7539}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{292680973}-8083}{15078}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8083/7539)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n14519", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(14519))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $109x \\equiv 1 \\pmod{2067}$.", + "Output Answer": [ + "$1555$" + ], + "Output Program": [ + "print(pow(109, -1, 2067))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $707x \\equiv 1 \\pmod{1956}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "print(pow(707, -1, 1956))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80450 \\pmod{88}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(80450 % 88)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $64^m \\equiv 1 \\pmod{403}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(64, 403))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53311 \\pmod{75}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(53311 % 75)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1781^295 \\pmod{2148}$.", + "Output Answer": [ + "$1913$" + ], + "Output Program": [ + "print(pow(1781, 295, 2148))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2141}{545}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5771981}-2141}{1090}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2141/545)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 3 \\pmod{8}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 3), (3, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 3), (3, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 3), (3, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{11699}{5277}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{248253517}-11699}{10554}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11699/5277)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{8}$\n$x \\equiv 6 \\pmod{13}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 8), (6, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 8), (6, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (11, 8), (6, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{16}$\n$x \\equiv 9 \\pmod{12}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (9, 16), (9, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 16), (9, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2420^2275 \\pmod{2826}$.", + "Output Answer": [ + "$656$" + ], + "Output Program": [ + "print(pow(2420, 2275, 2826))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24563 \\pmod{79}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(24563 % 79)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5276)$.", + "Output Answer": [ + "$2636$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5276))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{203,3,659\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 203, 3, 659\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $431^m \\equiv 1 \\pmod{774}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(431, 774))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36111 \\pmod{30}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(36111 % 30)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-20850$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-20850 % 30 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9216)$.", + "Output Answer": [ + "$3072$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9216))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14497)$.", + "Output Answer": [ + "$11664$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14497))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47330)$.", + "Output Answer": [ + "$18928$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47330))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.1$ to base $19$.", + "Output Answer": [ + "$\\text{0.1h1h2}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.1\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4962}{17521}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{313140802}-2481}{17521}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4962/17521)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $83x \\equiv 1 \\pmod{1365}$.", + "Output Answer": [ + "$1217$" + ], + "Output Program": [ + "print(pow(83, -1, 1365))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $269^m \\equiv 1 \\pmod{970}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(269, 970))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2079^1784 \\pmod{2223}$.", + "Output Answer": [ + "$729$" + ], + "Output Program": [ + "print(pow(2079, 1784, 2223))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2107$ to base $22$.", + "Output Answer": [ + "$\\text{47h}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2107\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{418,289\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 418, 289\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2149^916 \\pmod{2416}$.", + "Output Answer": [ + "$1985$" + ], + "Output Program": [ + "print(pow(2149, 916, 2416))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{911,490\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 911, 490\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58239 \\pmod{64}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(58239 % 64)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $211^m \\equiv 1 \\pmod{285}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(211, 285))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{37773}{14600}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2279439529}-37773}{29200}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37773/14600)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32988)$.", + "Output Answer": [ + "$10992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32988))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n16369", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16369))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1787^1396 \\pmod{2719}$.", + "Output Answer": [ + "$1434$" + ], + "Output Program": [ + "print(pow(1787, 1396, 2719))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n65117", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65117))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84665 \\pmod{14}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(84665 % 14)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $553^m \\equiv 1 \\pmod{935}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(553, 935))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 16 \\pmod{9}$\n$x \\equiv 16 \\pmod{11}$", + "Output Answer": [ + "$1105$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 17), (16, 9), (16, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 17), (16, 9), (16, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 17), (16, 9), (16, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-534,-76\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -534, -76\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1093x \\equiv 1 \\pmod{1546}$.", + "Output Answer": [ + "$587$" + ], + "Output Program": [ + "print(pow(1093, -1, 1546))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1385^574 \\pmod{1952}$.", + "Output Answer": [ + "$1713$" + ], + "Output Program": [ + "print(pow(1385, 574, 1952))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n21499", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21499))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-804$ is divisible by $-24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-804 % -24 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $71^1865 \\pmod{2419}$.", + "Output Answer": [ + "$2258$" + ], + "Output Program": [ + "print(pow(71, 1865, 2419))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-779,-103\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -779, -103\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{275,-413\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 275, -413\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55591 \\pmod{47}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(55591 % 47)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{553,569,-307\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 553, 569, -307\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 18 \\pmod{7}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 16), (18, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 16), (18, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (0, 16), (18, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6023}{15202}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{960679745}-6023}{30404}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6023/15202)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{49,-483\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 49, -483\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $7^2031 \\pmod{998}$.", + "Output Answer": [ + "$721$" + ], + "Output Program": [ + "print(pow(7, 2031, 998))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $351^m \\equiv 1 \\pmod{658}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(351, 658))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $724^605 \\pmod{2744}$.", + "Output Answer": [ + "$544$" + ], + "Output Program": [ + "print(pow(724, 605, 2744))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30285 \\pmod{49}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(30285 % 49)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28865)$.", + "Output Answer": [ + "$22000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28865))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $616x \\equiv 1 \\pmod{1501}$.", + "Output Answer": [ + "$943$" + ], + "Output Program": [ + "print(pow(616, -1, 1501))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8537$.", + "Output Answer": [ + "$\\{3,5,6,10,12,17,20,21,24,27\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8537):\n if len(roots) == 10: break\n if gcd(a, 8537) == 1 and is_primitive_root(a, 8537):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32261)$.", + "Output Answer": [ + "$32260$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32261))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-407$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-407 % 18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $5925$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5925 % 25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{37,-526,-122\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 37, -526, -122\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58561 \\pmod{44}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "print(58561 % 44)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{18}$\n$x \\equiv 10 \\pmod{11}$", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 18), (10, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 18), (10, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 18), (10, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10120}{993}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{993} \\left(\\sqrt{26589649}-5060\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10120/993)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9399)$.", + "Output Answer": [ + "$5760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9399))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $627^m \\equiv 1 \\pmod{862}$.", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(627, 862))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $254^986 \\pmod{1418}$.", + "Output Answer": [ + "$860$" + ], + "Output Program": [ + "print(pow(254, 986, 1418))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{629,-545\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 629, -545\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1488^1897 \\pmod{2534}$.", + "Output Answer": [ + "$1418$" + ], + "Output Program": [ + "print(pow(1488, 1897, 2534))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n83777", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83777))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{440,-590,91\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 440, -590, 91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $259^m \\equiv 1 \\pmod{754}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(259, 754))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26188)$.", + "Output Answer": [ + "$13092$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26188))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{19}{1110}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4928761}-19}{2220}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19/1110)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $85^2198 \\pmod{1815}$.", + "Output Answer": [ + "$280$" + ], + "Output Program": [ + "print(pow(85, 2198, 1815))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{9}$\n$x \\equiv 10 \\pmod{5}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "constraints = (6, 9), (10, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 9), (10, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 9), (10, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1486^199 \\pmod{1544}$.", + "Output Answer": [ + "$1088$" + ], + "Output Program": [ + "print(pow(1486, 199, 1544))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54886 \\pmod{45}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(54886 % 45)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-275,149,18\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -275, 149, 18\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1591$ to base $25$.", + "Output Answer": [ + "$\\text{2dg}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1591\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $143x \\equiv 1 \\pmod{1457}$.", + "Output Answer": [ + "$917$" + ], + "Output Program": [ + "print(pow(143, -1, 1457))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{19}$\n$x \\equiv 19 \\pmod{14}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$761$" + ], + "Output Program": [ + "constraints = (1, 19), (19, 14), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 19), (19, 14), (13, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 19), (19, 14), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $25849$.", + "Output Answer": [ + "$\\{7,11,21,26,28,29,31,33,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(25849):\n if len(roots) == 10: break\n if gcd(a, 25849) == 1 and is_primitive_root(a, 25849):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{4}$\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 2 \\pmod{19}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "constraints = (18, 4), (11, 9), (10, 8), (2, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 4), (11, 9), (10, 8), (2, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1212$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1212 % 32 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{489,-198,782\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 489, -198, 782\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1613^1425 \\pmod{2411}$.", + "Output Answer": [ + "$1233$" + ], + "Output Program": [ + "print(pow(1613, 1425, 2411))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $31583$.", + "Output Answer": [ + "$\\{5,10,13,15,17,19,20,23,26,29\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(31583):\n if len(roots) == 10: break\n if gcd(a, 31583) == 1 and is_primitive_root(a, 31583):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $254^222 \\pmod{366}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(pow(254, 222, 366))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79465 \\pmod{28}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(79465 % 28)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-790,855\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -790, 855\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 5 \\pmod{18}$", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "constraints = (11, 7), (7, 2), (5, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (7, 2), (5, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35593)$.", + "Output Answer": [ + "$35592$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35593))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{603,-771\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 603, -771\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1051}{105}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{210} \\left(\\sqrt{1148701}-1051\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1051/105)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{31}{11}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{22} \\left(17 \\sqrt{5}-31\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31/11)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41131$.", + "Output Answer": [ + "$\\{10,14,15,31,33,34,37,38,40,43\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41131):\n if len(roots) == 10: break\n if gcd(a, 41131) == 1 and is_primitive_root(a, 41131):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90400 \\pmod{44}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(90400 % 44)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $23186$.", + "Output Answer": [ + "$\\{5,43,45,57,67,73,85,89,99,103\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(23186):\n if len(roots) == 10: break\n if gcd(a, 23186) == 1 and is_primitive_root(a, 23186):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{19}$\n$x \\equiv 12 \\pmod{3}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (6, 19), (12, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 19), (12, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 19), (12, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1462^1842 \\pmod{2287}$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "print(pow(1462, 1842, 2287))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $136^m \\equiv 1 \\pmod{145}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(136, 145))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{8}$\n$x \\equiv 5 \\pmod{19}$", + "Output Answer": [ + "$119$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 8), (5, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 8), (5, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 8), (5, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{317}{1448}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8487305}-317}{2896}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(317/1448)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-369,815\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -369, 815\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2519$ to base $35$.", + "Output Answer": [ + "$\\text{21y}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2519\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1224$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1224 % -12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $84^m \\equiv 1 \\pmod{149}$.", + "Output Answer": [ + "$148$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(84, 149))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $481$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(481 % 31 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $119$ to base $30$.", + "Output Answer": [ + "$\\text{3t}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 119\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2231^892 \\pmod{2234}$.", + "Output Answer": [ + "$1381$" + ], + "Output Program": [ + "print(pow(2231, 892, 2234))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17961)$.", + "Output Answer": [ + "$11972$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17961))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $810x \\equiv 1 \\pmod{1001}$.", + "Output Answer": [ + "$283$" + ], + "Output Program": [ + "print(pow(810, -1, 1001))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{21814}{11911}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{260834570}-10907}{11911}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21814/11911)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-952,-443,264\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -952, -443, 264\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-742$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-742 % -18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42941)$.", + "Output Answer": [ + "$41052$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42941))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{7}$\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 20 \\pmod{15}$", + "Output Answer": [ + "$290$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 7), (11, 9), (20, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 7), (11, 9), (20, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n59199", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59199))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51600 \\pmod{34}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(51600 % 34)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22794)$.", + "Output Answer": [ + "$7280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22794))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 10 \\pmod{7}$", + "Output Answer": [ + "$388$" + ], + "Output Program": [ + "constraints = (8, 19), (4, 16), (10, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (4, 16), (10, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 19), (4, 16), (10, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1292$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1292 % -26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{11}$\n$x \\equiv 10 \\pmod{4}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 11), (10, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 11), (10, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 11), (10, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42827)$.", + "Output Answer": [ + "$42336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42827))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37608)$.", + "Output Answer": [ + "$12528$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37608))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1008^2048 \\pmod{1047}$.", + "Output Answer": [ + "$312$" + ], + "Output Program": [ + "print(pow(1008, 2048, 1047))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $29207$.", + "Output Answer": [ + "$29207^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(29207))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $613x \\equiv 1 \\pmod{1662}$.", + "Output Answer": [ + "$385$" + ], + "Output Program": [ + "print(pow(613, -1, 1662))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-856,734\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -856, 734\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{23495}{15083}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1462002581}-23495}{30166}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23495/15083)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $17571$.", + "Output Answer": [ + "$3^1\\cdot 5857^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(17571))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-7824$ is divisible by $48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7824 % 48 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{3}$\n$x \\equiv 13 \\pmod{17}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 3), (13, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 3), (13, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 3), (13, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5442)$.", + "Output Answer": [ + "$1812$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5442))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $469$ to base $21$.", + "Output Answer": [ + "$117_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 469\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77896 \\pmod{22}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(77896 % 22)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2565$ to base $24$.", + "Output Answer": [ + "$\\text{4al}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2565\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $7630$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(7630 % 28 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $629^m \\equiv 1 \\pmod{921}$.", + "Output Answer": [ + "$306$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(629, 921))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-9590$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9590 % 14 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $66600$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(66600 % -37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $204x \\equiv 1 \\pmod{2153}$.", + "Output Answer": [ + "$1467$" + ], + "Output Program": [ + "print(pow(204, -1, 2153))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $95x \\equiv 1 \\pmod{887}$.", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "print(pow(95, -1, 887))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $143^m \\equiv 1 \\pmod{687}$.", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(143, 687))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71411 \\pmod{15}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(71411 % 15)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{214,65,107\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 214, 65, 107\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57118 \\pmod{82}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(57118 % 82)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $267x \\equiv 1 \\pmod{1585}$.", + "Output Answer": [ + "$653$" + ], + "Output Program": [ + "print(pow(267, -1, 1585))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{83,272,-200\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 83, 272, -200\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15622)$.", + "Output Answer": [ + "$7632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15622))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $111^165 \\pmod{463}$.", + "Output Answer": [ + "$308$" + ], + "Output Program": [ + "print(pow(111, 165, 463))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $705x \\equiv 1 \\pmod{1079}$.", + "Output Answer": [ + "$828$" + ], + "Output Program": [ + "print(pow(705, -1, 1079))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $117^m \\equiv 1 \\pmod{272}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(117, 272))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27853 \\pmod{52}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(27853 % 52)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $765^m \\equiv 1 \\pmod{808}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(765, 808))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1728$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1728 % 12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2645}{1803}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19999261}-2645}{3606}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2645/1803)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59228 \\pmod{87}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(59228 % 87)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 82828 \\pmod{66}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(82828 % 66)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{714}{251}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{251} \\left(5 \\sqrt{7618}-357\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(714/251)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $632^m \\equiv 1 \\pmod{649}$.", + "Output Answer": [ + "$290$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(632, 649))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90167 \\pmod{67}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(90167 % 67)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63441 \\pmod{72}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(63441 % 72)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 13), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 13), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n66491", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66491))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.408$ to base $33$.", + "Output Answer": [ + "$\\text{0.dfaa}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.408\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 20 \\pmod{16}$", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "constraints = (14, 17), (20, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 17), (20, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (20, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{18}$\n$x \\equiv 0 \\pmod{11}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "constraints = (4, 18), (0, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 18), (0, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 18), (0, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-593$ is divisible by $34$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-593 % 34 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{23811}{11950}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1138173721}-23811}{23900}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23811/11950)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{2}$\n$x \\equiv 1 \\pmod{6}$\n$x \\equiv 5 \\pmod{11}$\n$x \\equiv 0 \\pmod{5}$", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 2), (1, 6), (5, 11), (0, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 2), (1, 6), (5, 11), (0, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $250$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(250 % -32 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24484)$.", + "Output Answer": [ + "$12240$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24484))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $61705$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(61705 % 43 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $58590$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(58590 % -42 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{461,-39,530\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 461, -39, 530\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-41,-236\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -41, -236\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{247,-724,17\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 247, -724, 17\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25563)$.", + "Output Answer": [ + "$17040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25563))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86380 \\pmod{18}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(86380 % 18)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-132,157\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -132, 157\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1811x \\equiv 1 \\pmod{2376}$.", + "Output Answer": [ + "$635$" + ], + "Output Program": [ + "print(pow(1811, -1, 2376))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32131)$.", + "Output Answer": [ + "$27720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32131))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $53$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(53 % -9 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n26425", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26425))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-3000$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3000 % 18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $241^m \\equiv 1 \\pmod{385}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(241, 385))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45230)$.", + "Output Answer": [ + "$18088$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45230))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2403^848 \\pmod{2911}$.", + "Output Answer": [ + "$2497$" + ], + "Output Program": [ + "print(pow(2403, 848, 2911))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2434^113 \\pmod{2752}$.", + "Output Answer": [ + "$1280$" + ], + "Output Program": [ + "print(pow(2434, 113, 2752))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $451^m \\equiv 1 \\pmod{544}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(451, 544))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1744^190 \\pmod{2839}$.", + "Output Answer": [ + "$2286$" + ], + "Output Program": [ + "print(pow(1744, 190, 2839))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $938x \\equiv 1 \\pmod{2259}$.", + "Output Answer": [ + "$1274$" + ], + "Output Program": [ + "print(pow(938, -1, 2259))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37838)$.", + "Output Answer": [ + "$18918$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37838))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $35111$.", + "Output Answer": [ + "$\\{13,17,23,26,29,34,37,39,41,43\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(35111):\n if len(roots) == 10: break\n if gcd(a, 35111) == 1 and is_primitive_root(a, 35111):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68165 \\pmod{24}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(68165 % 24)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97070 \\pmod{79}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "print(97070 % 79)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $988x \\equiv 1 \\pmod{1715}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "print(pow(988, -1, 1715))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1466x \\equiv 1 \\pmod{2091}$.", + "Output Answer": [ + "$455$" + ], + "Output Program": [ + "print(pow(1466, -1, 2091))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5324}{8067}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{72162733}-2662}{8067}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5324/8067)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $952x \\equiv 1 \\pmod{1509}$.", + "Output Answer": [ + "$829$" + ], + "Output Program": [ + "print(pow(952, -1, 1509))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $305x \\equiv 1 \\pmod{602}$.", + "Output Answer": [ + "$527$" + ], + "Output Program": [ + "print(pow(305, -1, 602))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48944 \\pmod{71}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(48944 % 71)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $880^2132 \\pmod{1008}$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "print(pow(880, 2132, 1008))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1281 \\pmod{29}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(1281 % 29)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68261 \\pmod{28}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(68261 % 28)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-692,-288\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -692, -288\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1803^785 \\pmod{2261}$.", + "Output Answer": [ + "$1752$" + ], + "Output Program": [ + "print(pow(1803, 785, 2261))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2494^1185 \\pmod{2550}$.", + "Output Answer": [ + "$1474$" + ], + "Output Program": [ + "print(pow(2494, 1185, 2550))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{445,266,19\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 445, 266, 19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1982^981 \\pmod{2459}$.", + "Output Answer": [ + "$127$" + ], + "Output Program": [ + "print(pow(1982, 981, 2459))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33713 \\pmod{59}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(33713 % 59)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $368$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(368 % -23 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $751$ to base $2$.", + "Output Answer": [ + "$1011101111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 751\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $772^1721 \\pmod{950}$.", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "print(pow(772, 1721, 950))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1117x \\equiv 1 \\pmod{1350}$.", + "Output Answer": [ + "$1153$" + ], + "Output Program": [ + "print(pow(1117, -1, 1350))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-28,102,499\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -28, 102, 499\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $223^m \\equiv 1 \\pmod{525}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(223, 525))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{463}{880}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3311969}-463}{1760}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(463/880)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2429^507 \\pmod{2554}$.", + "Output Answer": [ + "$857$" + ], + "Output Program": [ + "print(pow(2429, 507, 2554))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-205,391\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -205, 391\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{557}{252}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{504} \\left(\\sqrt{564265}-557\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(557/252)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-556,677\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -556, 677\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2110^1330 \\pmod{2645}$.", + "Output Answer": [ + "$1890$" + ], + "Output Program": [ + "print(pow(2110, 1330, 2645))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2551 \\pmod{28}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(2551 % 28)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{17}$\n$x \\equiv 7 \\pmod{14}$\n$x \\equiv 11 \\pmod{9}$", + "Output Answer": [ + "$1883$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 17), (7, 14), (11, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 17), (7, 14), (11, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 17), (7, 14), (11, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{513,-538,-691\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 513, -538, -691\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8129}{8007}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{322528837}-8129}{16014}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8129/8007)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n76389", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76389))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1187$ to base $28$.", + "Output Answer": [ + "$\\text{1eb}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1187\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{198,979\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 198, 979\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $136$ is divisible by $6$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(136 % 6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2237^655 \\pmod{2845}$.", + "Output Answer": [ + "$1648$" + ], + "Output Program": [ + "print(pow(2237, 655, 2845))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{2}$\n$x \\equiv 0 \\pmod{12}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (6, 2), (0, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 2), (0, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1199^1838 \\pmod{2712}$.", + "Output Answer": [ + "$889$" + ], + "Output Program": [ + "print(pow(1199, 1838, 2712))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $778$ to base $13$.", + "Output Answer": [ + "$\\text{47b}_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 778\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-264$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-264 % -22 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34557)$.", + "Output Answer": [ + "$23036$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34557))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n6377", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6377))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-254$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-254 % -16 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{754,287,-688\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 754, 287, -688\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{277,355,-658\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 277, 355, -658\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $119^m \\equiv 1 \\pmod{484}$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(119, 484))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{14}$\n$x \\equiv 12 \\pmod{9}$\n$x \\equiv 6 \\pmod{8}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 14), (12, 9), (6, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 14), (12, 9), (6, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55877 \\pmod{61}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(55877 % 61)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $158^m \\equiv 1 \\pmod{235}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(158, 235))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{407,787,-696\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 407, 787, -696\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $11138$.", + "Output Answer": [ + "$\\{13,17,19,39,43,47,57,61,65,67\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(11138):\n if len(roots) == 10: break\n if gcd(a, 11138) == 1 and is_primitive_root(a, 11138):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1831^2011 \\pmod{2060}$.", + "Output Answer": [ + "$951$" + ], + "Output Program": [ + "print(pow(1831, 2011, 2060))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $138x \\equiv 1 \\pmod{841}$.", + "Output Answer": [ + "$323$" + ], + "Output Program": [ + "print(pow(138, -1, 841))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60077 \\pmod{56}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(60077 % 56)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-113,223\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -113, 223\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1048}{26865}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{722002801}-524}{26865}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1048/26865)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4932)$.", + "Output Answer": [ + "$1632$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4932))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $158^m \\equiv 1 \\pmod{717}$.", + "Output Answer": [ + "$238$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(158, 717))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{105}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 105))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 17 \\pmod{6}$", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (17, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 19), (17, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 19), (17, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 13 \\pmod{13}$\n$x \\equiv 3 \\pmod{19}$", + "Output Answer": [ + "$1105$" + ], + "Output Program": [ + "import math\n\nconstraints = (16, 11), (13, 13), (3, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 11), (13, 13), (3, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 11), (13, 13), (3, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $297x \\equiv 1 \\pmod{1121}$.", + "Output Answer": [ + "$502$" + ], + "Output Program": [ + "print(pow(297, -1, 1121))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $737x \\equiv 1 \\pmod{1508}$.", + "Output Answer": [ + "$133$" + ], + "Output Program": [ + "print(pow(737, -1, 1508))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $899^m \\equiv 1 \\pmod{942}$.", + "Output Answer": [ + "$156$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(899, 942))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 16 \\pmod{18}$\n$x \\equiv 16 \\pmod{8}$", + "Output Answer": [ + "$448$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 7), (16, 18), (16, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 7), (16, 18), (16, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $882x \\equiv 1 \\pmod{935}$.", + "Output Answer": [ + "$688$" + ], + "Output Program": [ + "print(pow(882, -1, 935))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{14903}{29814}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3777597793}-14903}{59628}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14903/29814)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92964 \\pmod{76}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(92964 % 76)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{16888}{17763}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{386825305}-8444}{17763}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16888/17763)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $739x \\equiv 1 \\pmod{1151}$.", + "Output Answer": [ + "$176$" + ], + "Output Program": [ + "print(pow(739, -1, 1151))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{2}$\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$156$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 2), (2, 11), (13, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 2), (2, 11), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 2), (2, 11), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $99327$.", + "Output Answer": [ + "$3^1\\cdot 113^1\\cdot 293^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(99327))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 3 \\pmod{13}$", + "Output Answer": [ + "$289$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 11), (17, 17), (3, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 11), (17, 17), (3, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 11), (17, 17), (3, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{2}$\n$x \\equiv 20 \\pmod{14}$\n$x \\equiv 19 \\pmod{19}$\n$x \\equiv 11 \\pmod{11}$", + "Output Answer": [ + "$1672$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 2), (20, 14), (19, 19), (11, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 2), (20, 14), (19, 19), (11, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $104$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(104 % -26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{14}$\n$x \\equiv 7 \\pmod{15}$\n$x \\equiv 13 \\pmod{4}$", + "Output Answer": [ + "$397$" + ], + "Output Program": [ + "constraints = (19, 14), (7, 15), (13, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 14), (7, 15), (13, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1591^2490 \\pmod{2015}$.", + "Output Answer": [ + "$311$" + ], + "Output Program": [ + "print(pow(1591, 2490, 2015))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7287)$.", + "Output Answer": [ + "$4152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7287))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2455x \\equiv 1 \\pmod{2472}$.", + "Output Answer": [ + "$727$" + ], + "Output Program": [ + "print(pow(2455, -1, 2472))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{12}$\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 9 \\pmod{13}$", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "constraints = (18, 12), (9, 13), (9, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 12), (9, 13), (9, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3906)$.", + "Output Answer": [ + "$1080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3906))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42413)$.", + "Output Answer": [ + "$35424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42413))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77658 \\pmod{76}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(77658 % 76)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $11492$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(11492 % -26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $16050$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(16050 % -25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3576}{2555}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9724969}-1788}{2555}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3576/2555)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2260^153 \\pmod{2493}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(2260, 153, 2493))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{41,343\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 41, 343\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{12}$\n$x \\equiv 3 \\pmod{2}$\n$x \\equiv 11 \\pmod{17}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 12), (3, 2), (11, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 12), (3, 2), (11, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $26458$.", + "Output Answer": [ + "$\\{3,7,11,13,15,17,27,31,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(26458):\n if len(roots) == 10: break\n if gcd(a, 26458) == 1 and is_primitive_root(a, 26458):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $167^m \\equiv 1 \\pmod{621}$.", + "Output Answer": [ + "$198$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(167, 621))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $983x \\equiv 1 \\pmod{1068}$.", + "Output Answer": [ + "$779$" + ], + "Output Program": [ + "print(pow(983, -1, 1068))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 18 \\pmod{14}$\n$x \\equiv 4 \\pmod{7}$\n$x \\equiv 18 \\pmod{13}$", + "Output Answer": [ + "$1656$" + ], + "Output Program": [ + "constraints = (6, 15), (18, 14), (4, 7), (18, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 15), (18, 14), (4, 7), (18, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $151$ is divisible by $-6$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(151 % -6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{166}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(pow(37, -1, 166))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 20 \\pmod{18}$", + "Output Answer": [ + "$128$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 11), (20, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 11), (20, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 11), (20, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1095^1378 \\pmod{2213}$.", + "Output Answer": [ + "$600$" + ], + "Output Program": [ + "print(pow(1095, 1378, 2213))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2815}{2887}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{41263301}-2815}{5774}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2815/2887)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $10222221_3$ to base 10.", + "Output Answer": [ + "$2914$" + ], + "Output Program": [ + "n = '10222221'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-7238$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7238 % -14 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $64^m \\equiv 1 \\pmod{361}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(64, 361))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $60x \\equiv 1 \\pmod{281}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(60, -1, 281))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{4,0,5,-3\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = 4, 0, 5, -3\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{560,-527,153\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 560, -527, 153\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{42,-476\\}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "import math\n\nvalues = 42, -476\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(872)$.", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(872))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n64873", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64873))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-837,244,361\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -837, 244, 361\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98513 \\pmod{48}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(98513 % 48)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1324^1406 \\pmod{2122}$.", + "Output Answer": [ + "$1192$" + ], + "Output Program": [ + "print(pow(1324, 1406, 2122))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54827 \\pmod{31}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(54827 % 31)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{6}$\n$x \\equiv 15 \\pmod{11}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 6), (15, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 6), (15, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 6), (15, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-62$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-62 % -44 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{694,-890\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 694, -890\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77014 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(77014 % 6)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $173_{26}$ to base 10.", + "Output Answer": [ + "$861$" + ], + "Output Program": [ + "n = '173'.strip('.')\nbase = 26\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1139x \\equiv 1 \\pmod{1728}$.", + "Output Answer": [ + "$443$" + ], + "Output Program": [ + "print(pow(1139, -1, 1728))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $197^m \\equiv 1 \\pmod{710}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(197, 710))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6362)$.", + "Output Answer": [ + "$3180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6362))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2325^1186 \\pmod{2716}$.", + "Output Answer": [ + "$897$" + ], + "Output Program": [ + "print(pow(2325, 1186, 2716))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{14}$\n$x \\equiv 1 \\pmod{15}$", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 14), (1, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 14), (1, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 14), (1, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{933}{2072}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{721729}-933}{4144}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(933/2072)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{449,-169,978\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 449, -169, 978\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{24521}{44323}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8459392757}-24521}{88646}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24521/44323)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{4}$\n$x \\equiv 18 \\pmod{14}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 4), (18, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 4), (18, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2344}{381}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{381} \\left(\\sqrt{1518745}-1172\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2344/381)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{18}$\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 15 \\pmod{5}$", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 18), (3, 8), (15, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 18), (3, 8), (15, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{5}$\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 9 \\pmod{17}$\n$x \\equiv 2 \\pmod{10}$", + "Output Answer": [ + "$842$" + ], + "Output Program": [ + "constraints = (7, 5), (6, 11), (9, 17), (2, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 5), (6, 11), (9, 17), (2, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $274^1904 \\pmod{2348}$.", + "Output Answer": [ + "$724$" + ], + "Output Program": [ + "print(pow(274, 1904, 2348))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n33159", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33159))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22528 \\pmod{46}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(22528 % 46)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19175)$.", + "Output Answer": [ + "$13920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19175))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $888x \\equiv 1 \\pmod{1325}$.", + "Output Answer": [ + "$852$" + ], + "Output Program": [ + "print(pow(888, -1, 1325))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $612^335 \\pmod{1079}$.", + "Output Answer": [ + "$950$" + ], + "Output Program": [ + "print(pow(612, 335, 1079))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1637}{13406}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{721563113}-1637}{26812}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1637/13406)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57398 \\pmod{30}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(57398 % 30)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-327,65,-287\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -327, 65, -287\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1851x \\equiv 1 \\pmod{2365}$.", + "Output Answer": [ + "$796$" + ], + "Output Program": [ + "print(pow(1851, -1, 2365))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2395^518 \\pmod{2636}$.", + "Output Answer": [ + "$2413$" + ], + "Output Program": [ + "print(pow(2395, 518, 2636))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $5413$.", + "Output Answer": [ + "$\\{5,6,13,15,17,18,20,24,29,38\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(5413):\n if len(roots) == 10: break\n if gcd(a, 5413) == 1 and is_primitive_root(a, 5413):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $523x \\equiv 1 \\pmod{936}$.", + "Output Answer": [ + "$451$" + ], + "Output Program": [ + "print(pow(523, -1, 936))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $45210$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 5^1\\cdot 11^1\\cdot 137^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(45210))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $112^m \\equiv 1 \\pmod{117}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(112, 117))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2443^400 \\pmod{2709}$.", + "Output Answer": [ + "$2443$" + ], + "Output Program": [ + "print(pow(2443, 400, 2709))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43353)$.", + "Output Answer": [ + "$28896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43353))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-61711$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-61711 % 47 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13454)$.", + "Output Answer": [ + "$5580$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13454))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27250)$.", + "Output Answer": [ + "$10800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27250))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $967^1659 \\pmod{1600}$.", + "Output Answer": [ + "$1303$" + ], + "Output Program": [ + "print(pow(967, 1659, 1600))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $611^166 \\pmod{1700}$.", + "Output Answer": [ + "$1361$" + ], + "Output Program": [ + "print(pow(611, 166, 1700))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-763,320\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -763, 320\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n56499", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(56499))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1018$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1018 % -48 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{15}$\n$x \\equiv 2 \\pmod{5}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 15), (2, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 15), (2, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n86357", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(86357))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{533}{673}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2095805}-533}{1346}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(533/673)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{17}$\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 18 \\pmod{6}$", + "Output Answer": [ + "$264$" + ], + "Output Program": [ + "constraints = (9, 17), (16, 8), (18, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 17), (16, 8), (18, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $488^1141 \\pmod{1367}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(488, 1141, 1367))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27623)$.", + "Output Answer": [ + "$26400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27623))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32637 \\pmod{35}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(32637 % 35)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $42769$.", + "Output Answer": [ + "$19^1\\cdot 2251^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(42769))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 9 \\pmod{6}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (9, 14), (9, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (9, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1348^1609 \\pmod{2108}$.", + "Output Answer": [ + "$556$" + ], + "Output Program": [ + "print(pow(1348, 1609, 2108))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{6}$\n$x \\equiv 11 \\pmod{7}$", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 6), (11, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 6), (11, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 6), (11, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2472^1070 \\pmod{2898}$.", + "Output Answer": [ + "$2556$" + ], + "Output Program": [ + "print(pow(2472, 1070, 2898))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 3), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 3), (11, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26946)$.", + "Output Answer": [ + "$8964$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26946))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $331^906 \\pmod{1870}$.", + "Output Answer": [ + "$1101$" + ], + "Output Program": [ + "print(pow(331, 906, 1870))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 3 \\pmod{18}$\n$x \\equiv 9 \\pmod{16}$\n$x \\equiv 1 \\pmod{20}$", + "Output Answer": [ + "$201$" + ], + "Output Program": [ + "constraints = (3, 11), (3, 18), (9, 16), (1, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 11), (3, 18), (9, 16), (1, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1793}{1465}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{69821}-1793}{2930}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1793/1465)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-622,633\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -622, 633\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8913)$.", + "Output Answer": [ + "$5940$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8913))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10404}{8329}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{96433045}-5202}{8329}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10404/8329)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{756,-395,87\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 756, -395, 87\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-48116$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-48116 % -46 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{745,553,700\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 745, 553, 700\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30418)$.", + "Output Answer": [ + "$14916$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30418))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1408^1067 \\pmod{1603}$.", + "Output Answer": [ + "$603$" + ], + "Output Program": [ + "print(pow(1408, 1067, 1603))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 1 \\pmod{15}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 2), (1, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 2), (1, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 2), (1, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1791^889 \\pmod{2029}$.", + "Output Answer": [ + "$1268$" + ], + "Output Program": [ + "print(pow(1791, 889, 2029))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{179,1,-2\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 179, 1, -2\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{20}$\n$x \\equiv 2 \\pmod{18}$", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "constraints = (14, 20), (2, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 20), (2, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $774$ to base $28$.", + "Output Answer": [ + "$\\text{ri}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 774\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-409,-438\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -409, -438\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n102259", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102259))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $32838$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 13^1\\cdot 421^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(32838))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17883 \\pmod{22}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(17883 % 22)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{72,591\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 72, 591\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n8019", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(8019))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $541^m \\equiv 1 \\pmod{622}$.", + "Output Answer": [ + "$310$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(541, 622))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $42204_5$ to base 10.", + "Output Answer": [ + "$2804$" + ], + "Output Program": [ + "n = '42204'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2028^1857 \\pmod{2990}$.", + "Output Answer": [ + "$1508$" + ], + "Output Program": [ + "print(pow(2028, 1857, 2990))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $720$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(720 % -8 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{812,289\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 812, 289\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{40,315,171\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 40, 315, 171\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{18538}{18385}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{423922586}-9269}{18385}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18538/18385)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $3576$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3576 % 12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $34^m \\equiv 1 \\pmod{125}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(34, 125))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{746,-881\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 746, -881\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38937 \\pmod{57}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(38937 % 57)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{988}{13821}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{191264077}-494}{13821}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(988/13821)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $681$ is divisible by $45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(681 % 45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $45$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(45 % -11 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $194$ to base $16$.", + "Output Answer": [ + "$\\text{c2}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 194\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{719,503,-639\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 719, 503, -639\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $87^m \\equiv 1 \\pmod{998}$.", + "Output Answer": [ + "$498$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(87, 998))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{19}$\n$x \\equiv 13 \\pmod{15}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$838$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 19), (13, 15), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (2, 19), (13, 15), (5, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 19), (13, 15), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-410,-393\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -410, -393\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4792}{23837}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{573943385}-2396}{23837}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4792/23837)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-14425$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-14425 % 25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13747)$.", + "Output Answer": [ + "$13456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13747))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10894}{7043}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{79273658}-5447}{7043}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10894/7043)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5654)$.", + "Output Answer": [ + "$2560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5654))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-484,-933,131\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -484, -933, 131\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{148}{283}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{283} \\left(\\sqrt{85565}-74\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(148/283)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3157)$.", + "Output Answer": [ + "$2400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3157))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35766)$.", + "Output Answer": [ + "$11916$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35766))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4938)$.", + "Output Answer": [ + "$1644$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4938))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $903$ to base $32$.", + "Output Answer": [ + "$\\text{s7}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 903\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5945}{343}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{686} \\left(\\sqrt{35813621}-5945\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5945/343)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27267)$.", + "Output Answer": [ + "$17760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27267))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{11778}{6223}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{2936242}-5889}{6223}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11778/6223)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $312^m \\equiv 1 \\pmod{673}$.", + "Output Answer": [ + "$336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(312, 673))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $65^1582 \\pmod{774}$.", + "Output Answer": [ + "$259$" + ], + "Output Program": [ + "print(pow(65, 1582, 774))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.573$ to base $32$.", + "Output Answer": [ + "$\\text{0.iao2}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.573\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{17}$\n$x \\equiv 8 \\pmod{16}$\n$x \\equiv 13 \\pmod{3}$", + "Output Answer": [ + "$280$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 17), (8, 16), (13, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 17), (8, 16), (13, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 17), (8, 16), (13, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{455,-804\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 455, -804\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $847^926 \\pmod{1439}$.", + "Output Answer": [ + "$662$" + ], + "Output Program": [ + "print(pow(847, 926, 1439))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98399 \\pmod{36}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(98399 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{891,-296\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 891, -296\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{124}{159}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{159} \\left(5 \\sqrt{1165}-62\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(124/159)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9720)$.", + "Output Answer": [ + "$2592$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9720))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-3726$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3726 % 18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76660 \\pmod{3}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(76660 % 3)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $119^m \\equiv 1 \\pmod{978}$.", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(119, 978))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $32360$.", + "Output Answer": [ + "$2^3\\cdot 5^1\\cdot 809^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(32360))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1240$ to base $31$.", + "Output Answer": [ + "$190_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1240\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{17}$\n$x \\equiv 6 \\pmod{8}$", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 17), (6, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 17), (6, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 17), (6, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $173^m \\equiv 1 \\pmod{200}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(173, 200))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{29626}{15621}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{463440610}-14813}{15621}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29626/15621)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94156 \\pmod{5}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(94156 % 5)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n16229", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16229))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{706,66\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 706, 66\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-576,293,825\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -576, 293, 825\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2687)$.", + "Output Answer": [ + "$2686$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2687))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{19}$\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 6 \\pmod{10}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "constraints = (17, 19), (6, 15), (6, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 19), (6, 15), (6, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{35984}{6863}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{370812833}-17992}{6863}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(35984/6863)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-128$ is divisible by $10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-128 % 10 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $185^m \\equiv 1 \\pmod{544}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(185, 544))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1211$ to base $36$.", + "Output Answer": [ + "$\\text{xn}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1211\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{141}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(pow(37, -1, 141))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36361 \\pmod{87}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "print(36361 % 87)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{17}$\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 7 \\pmod{8}$", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "constraints = (18, 17), (13, 5), (7, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 17), (13, 5), (7, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 17), (13, 5), (7, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n39293", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(39293))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66932 \\pmod{43}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(66932 % 43)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.002123221132_4$ to base 10.", + "Output Answer": [ + "$0.038$" + ], + "Output Program": [ + "n = '0.002123221132'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{826,-148\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 826, -148\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35647)$.", + "Output Answer": [ + "$34776$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35647))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{332}{203}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{203} \\left(\\sqrt{68765}-166\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(332/203)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1319x \\equiv 1 \\pmod{2050}$.", + "Output Answer": [ + "$129$" + ], + "Output Program": [ + "print(pow(1319, -1, 2050))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $16007$.", + "Output Answer": [ + "$\\{5,10,15,17,19,20,30,34,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(16007):\n if len(roots) == 10: break\n if gcd(a, 16007) == 1 and is_primitive_root(a, 16007):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $529^m \\equiv 1 \\pmod{958}$.", + "Output Answer": [ + "$239$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(529, 958))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5590}{6399}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{48759226}-2795}{6399}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5590/6399)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2178^673 \\pmod{2189}$.", + "Output Answer": [ + "$121$" + ], + "Output Program": [ + "print(pow(2178, 673, 2189))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10620 \\pmod{65}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(10620 % 65)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{189,224\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 189, 224\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{573,883\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 573, 883\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9574}{8507}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{95284418}-4787}{8507}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9574/8507)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $102$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 17^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(102))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-16954$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-16954 % -49 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $481^m \\equiv 1 \\pmod{794}$.", + "Output Answer": [ + "$396$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(481, 794))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{212,945,-531\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 212, 945, -531\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-13120$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-13120 % -41 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $351x \\equiv 1 \\pmod{890}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(pow(351, -1, 890))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $89^m \\equiv 1 \\pmod{352}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(89, 352))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $207^m \\equiv 1 \\pmod{212}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(207, 212))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $85x \\equiv 1 \\pmod{1108}$.", + "Output Answer": [ + "$365$" + ], + "Output Program": [ + "print(pow(85, -1, 1108))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1907x \\equiv 1 \\pmod{1947}$.", + "Output Answer": [ + "$146$" + ], + "Output Program": [ + "print(pow(1907, -1, 1947))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $539^m \\equiv 1 \\pmod{655}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(539, 655))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,2\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 2\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $61x \\equiv 1 \\pmod{517}$.", + "Output Answer": [ + "$178$" + ], + "Output Program": [ + "print(pow(61, -1, 517))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1958$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1958 % -11 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $324x \\equiv 1 \\pmod{581}$.", + "Output Answer": [ + "$529$" + ], + "Output Program": [ + "print(pow(324, -1, 581))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 0 \\pmod{20}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "constraints = (8, 19), (0, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (0, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 19), (0, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{15315}{10106}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{643074169}-15315}{20212}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15315/10106)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $229$ to base $6$.", + "Output Answer": [ + "$1021_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 229\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20156 \\pmod{15}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(20156 % 15)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $781x \\equiv 1 \\pmod{922}$.", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "print(pow(781, -1, 922))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1325$ to base $17$.", + "Output Answer": [ + "$\\text{49g}_{17}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 17\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1325\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-238$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-238 % -7 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{41}{289}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{578} \\left(\\sqrt{335765}-41\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(41/289)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-24541$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-24541 % -23 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 2 \\pmod{15}$", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 14), (2, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 14), (2, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 14), (2, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2208^167 \\pmod{2376}$.", + "Output Answer": [ + "$1080$" + ], + "Output Program": [ + "print(pow(2208, 167, 2376))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $647^956 \\pmod{2566}$.", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "print(pow(647, 956, 2566))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $4280$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4280 % 20 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45547)$.", + "Output Answer": [ + "$44280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45547))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(999)$.", + "Output Answer": [ + "$648$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(999))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{20}$\n$x \\equiv 6 \\pmod{16}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "constraints = (2, 20), (6, 16), (4, 3), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 20), (6, 16), (4, 3), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-21600$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-21600 % 30 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $611^m \\equiv 1 \\pmod{990}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(611, 990))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-372,-729\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -372, -729\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $15x \\equiv 1 \\pmod{469}$.", + "Output Answer": [ + "$344$" + ], + "Output Program": [ + "print(pow(15, -1, 469))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.622$ to base $7$.", + "Output Answer": [ + "$0.4232265_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.622\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $571$ to base $36$.", + "Output Answer": [ + "$\\text{fv}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 571\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-17206$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-17206 % 28 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26730 \\pmod{28}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(26730 % 28)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $840x \\equiv 1 \\pmod{1307}$.", + "Output Answer": [ + "$431$" + ], + "Output Program": [ + "print(pow(840, -1, 1307))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{22026}{20279}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{532524010}-11013}{20279}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22026/20279)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $335$ to base $26$.", + "Output Answer": [ + "$\\text{cn}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 335\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1623x \\equiv 1 \\pmod{2030}$.", + "Output Answer": [ + "$1217$" + ], + "Output Program": [ + "print(pow(1623, -1, 2030))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $425^595 \\pmod{1673}$.", + "Output Answer": [ + "$957$" + ], + "Output Program": [ + "print(pow(425, 595, 1673))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{8}$\n$x \\equiv 11 \\pmod{15}$", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 8), (11, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 8), (11, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 8), (11, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{834,263,-996\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 834, 263, -996\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{444,-600\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 444, -600\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13644)$.", + "Output Answer": [ + "$4536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13644))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71680 \\pmod{13}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(71680 % 13)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{242,-822,-469\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 242, -822, -469\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $211x \\equiv 1 \\pmod{369}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(211, -1, 369))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 15 \\pmod{17}$\n$x \\equiv 20 \\pmod{5}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "constraints = (3, 3), (15, 17), (20, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (3, 3), (15, 17), (20, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 3), (15, 17), (20, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-878,757\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -878, 757\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-741,-299\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -741, -299\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91391 \\pmod{50}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "print(91391 % 50)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1}{271}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{542} \\left(\\sqrt{293765}-1\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1/271)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-72,-798\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -72, -798\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1514^1182 \\pmod{2473}$.", + "Output Answer": [ + "$1580$" + ], + "Output Program": [ + "print(pow(1514, 1182, 2473))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $163x \\equiv 1 \\pmod{2410}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(163, -1, 2410))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17740)$.", + "Output Answer": [ + "$7088$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17740))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9639}{11243}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{598530517}-9639}{22486}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9639/11243)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $475^m \\equiv 1 \\pmod{786}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(475, 786))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{155,273,861\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 155, 273, 861\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9707}{3701}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{149015453}-9707}{7402}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9707/3701)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{793,-947\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 793, -947\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1536$ to base $6$.", + "Output Answer": [ + "$11040_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1536\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4235)$.", + "Output Answer": [ + "$2640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4235))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $179^m \\equiv 1 \\pmod{182}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(179, 182))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $971x \\equiv 1 \\pmod{1130}$.", + "Output Answer": [ + "$931$" + ], + "Output Program": [ + "print(pow(971, -1, 1130))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{16596}{7049}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{118545205}-8298}{7049}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16596/7049)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n103183", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(103183))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $251x \\equiv 1 \\pmod{810}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(pow(251, -1, 810))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $30466$.", + "Output Answer": [ + "$\\{3,5,19,27,29,33,35,39,41,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(30466):\n if len(roots) == 10: break\n if gcd(a, 30466) == 1 and is_primitive_root(a, 30466):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49208)$.", + "Output Answer": [ + "$24600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49208))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $4256$ is divisible by $-28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4256 % -28 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n84239", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(84239))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 1 \\pmod{8}$\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 5 \\pmod{10}$", + "Output Answer": [ + "$585$" + ], + "Output Program": [ + "constraints = (7, 17), (1, 8), (12, 3), (5, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 17), (1, 8), (12, 3), (5, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47688 \\pmod{55}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(47688 % 55)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15924 \\pmod{54}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(15924 % 54)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9964)$.", + "Output Answer": [ + "$4784$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9964))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20363 \\pmod{90}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(20363 % 90)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14425)$.", + "Output Answer": [ + "$11520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14425))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2297^1940 \\pmod{2328}$.", + "Output Answer": [ + "$673$" + ], + "Output Program": [ + "print(pow(2297, 1940, 2328))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31560)$.", + "Output Answer": [ + "$8384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31560))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n73675", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(73675))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $74390$ is divisible by $-43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(74390 % -43 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $52^m \\equiv 1 \\pmod{395}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(52, 395))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2441^1996 \\pmod{2844}$.", + "Output Answer": [ + "$97$" + ], + "Output Program": [ + "print(pow(2441, 1996, 2844))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $17x \\equiv 1 \\pmod{1519}$.", + "Output Answer": [ + "$1251$" + ], + "Output Program": [ + "print(pow(17, -1, 1519))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3499}{11256}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{519033145}-3499}{22512}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3499/11256)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40012)$.", + "Output Answer": [ + "$17136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40012))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10054)$.", + "Output Answer": [ + "$4560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10054))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $719^m \\equiv 1 \\pmod{847}$.", + "Output Answer": [ + "$330$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(719, 847))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1121x \\equiv 1 \\pmod{1362}$.", + "Output Answer": [ + "$989$" + ], + "Output Program": [ + "print(pow(1121, -1, 1362))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-384,268\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -384, 268\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $68444$.", + "Output Answer": [ + "$2^2\\cdot 71^1\\cdot 241^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(68444))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 8 \\pmod{7}$\n$x \\equiv 9 \\pmod{10}$", + "Output Answer": [ + "$589$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 11), (8, 7), (9, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 11), (8, 7), (9, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 11), (8, 7), (9, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $151x \\equiv 1 \\pmod{169}$.", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "print(pow(151, -1, 169))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n19393", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(19393))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{24909}{14747}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1490354317}-24909}{29494}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24909/14747)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-949$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-949 % -37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8957)$.", + "Output Answer": [ + "$8112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8957))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2014^2102 \\pmod{2042}$.", + "Output Answer": [ + "$314$" + ], + "Output Program": [ + "print(pow(2014, 2102, 2042))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{23083}{31224}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4432577593}-23083}{62448}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23083/31224)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16969)$.", + "Output Answer": [ + "$16660$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16969))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21750 \\pmod{19}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(21750 % 19)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1371_{13}$ to base 10.", + "Output Answer": [ + "$2796$" + ], + "Output Program": [ + "n = '1371'.strip('.')\nbase = 13\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $135^m \\equiv 1 \\pmod{296}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(135, 296))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1899^2197 \\pmod{2093}$.", + "Output Answer": [ + "$807$" + ], + "Output Program": [ + "print(pow(1899, 2197, 2093))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2741}{5184}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{115008505}-2741}{10368}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2741/5184)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26161)$.", + "Output Answer": [ + "$26160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26161))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12525)$.", + "Output Answer": [ + "$6640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12525))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2467$ to base $8$.", + "Output Answer": [ + "$4643_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2467\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{174,-462,427\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 174, -462, 427\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-109,-235\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -109, -235\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-4191$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4191 % -11 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $53251$.", + "Output Answer": [ + "$11^1\\cdot 47^1\\cdot 103^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(53251))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $749x \\equiv 1 \\pmod{1825}$.", + "Output Answer": [ + "$999$" + ], + "Output Program": [ + "print(pow(749, -1, 1825))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29088)$.", + "Output Answer": [ + "$9600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29088))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $12975$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(12975 % -25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41417)$.", + "Output Answer": [ + "$40836$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41417))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89647 \\pmod{50}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(89647 % 50)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1120^2295 \\pmod{1205}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "print(pow(1120, 2295, 1205))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30672 \\pmod{11}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(30672 % 11)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $615x \\equiv 1 \\pmod{1231}$.", + "Output Answer": [ + "$1229$" + ], + "Output Program": [ + "print(pow(615, -1, 1231))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 19 \\pmod{19}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 7), (19, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 7), (19, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 7), (19, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90964 \\pmod{40}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(90964 % 40)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12158)$.", + "Output Answer": [ + "$6078$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12158))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $55^m \\equiv 1 \\pmod{324}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(55, 324))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2083x \\equiv 1 \\pmod{2310}$.", + "Output Answer": [ + "$2137$" + ], + "Output Program": [ + "print(pow(2083, -1, 2310))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{878,479,829\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 878, 479, 829\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $26902$.", + "Output Answer": [ + "$\\{7,11,21,31,33,35,37,41,43,47\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(26902):\n if len(roots) == 10: break\n if gcd(a, 26902) == 1 and is_primitive_root(a, 26902):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{682,221,402\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 682, 221, 402\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1125$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1125 % -44 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1713^1423 \\pmod{2875}$.", + "Output Answer": [ + "$447$" + ], + "Output Program": [ + "print(pow(1713, 1423, 2875))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-86485$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-86485 % -49 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n98009", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(98009))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2173^1651 \\pmod{2700}$.", + "Output Answer": [ + "$1777$" + ], + "Output Program": [ + "print(pow(2173, 1651, 2700))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{810,175\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 810, 175\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $18$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18 % 6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{13637}{11560}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{720502169}-13637}{23120}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13637/11560)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $7x \\equiv 1 \\pmod{25}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(pow(7, -1, 25))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{422}{301}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{301} \\left(\\sqrt{135122}-211\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(422/301)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $35138$.", + "Output Answer": [ + "$\\{11,13,19,23,33,35,37,39,53,55\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(35138):\n if len(roots) == 10: break\n if gcd(a, 35138) == 1 and is_primitive_root(a, 35138):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{789}{46}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{92} \\left(\\sqrt{630985}-789\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(789/46)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n87425", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(87425))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-418$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-418 % -41 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{647}{2895}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{33942709}-647}{5790}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(647/2895)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{9}$\n$x \\equiv 10 \\pmod{20}$", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "constraints = (18, 9), (10, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 9), (10, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 9), (10, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{13}$\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 8 \\pmod{16}$", + "Output Answer": [ + "$1432$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 13), (4, 17), (8, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 13), (4, 17), (8, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 13), (4, 17), (8, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{37833}{21499}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3280163893}-37833}{42998}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37833/21499)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $357x \\equiv 1 \\pmod{634}$.", + "Output Answer": [ + "$531$" + ], + "Output Program": [ + "print(pow(357, -1, 634))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $651x \\equiv 1 \\pmod{664}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(pow(651, -1, 664))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 141 \\pmod{64}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(141 % 64)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{21677}{25612}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3093790505}-21677}{51224}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21677/25612)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $687^1132 \\pmod{2455}$.", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "print(pow(687, 1132, 2455))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $40161$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(40161 % 33 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{12468}{25861}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{707654077}-6234}{25861}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12468/25861)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 2), (19, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 2), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 2), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "constraints = (1, 3), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 3), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 3), (5, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2446)$.", + "Output Answer": [ + "$1222$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2446))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78524 \\pmod{95}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(78524 % 95)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17844)$.", + "Output Answer": [ + "$5944$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17844))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6087}{1891}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{51355093}-6087}{3782}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6087/1891)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1054}{4507}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{20590778}-527}{4507}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1054/4507)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n10035", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10035))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $183^m \\equiv 1 \\pmod{503}$.", + "Output Answer": [ + "$251$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(183, 503))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6449}{9688}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{417018977}-6449}{19376}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6449/9688)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $11^m \\equiv 1 \\pmod{921}$.", + "Output Answer": [ + "$306$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(11, 921))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33424)$.", + "Output Answer": [ + "$16704$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33424))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $289^m \\equiv 1 \\pmod{490}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(289, 490))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2319$ to base $5$.", + "Output Answer": [ + "$33234_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2319\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n6839", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6839))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12678 \\pmod{15}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(12678 % 15)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37617)$.", + "Output Answer": [ + "$25076$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37617))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13839)$.", + "Output Answer": [ + "$7896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13839))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-514,-529\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -514, -529\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $223200_4$ to base 10.", + "Output Answer": [ + "$2784$" + ], + "Output Program": [ + "n = '223200'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{815,-635\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 815, -635\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n32569", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(32569))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{10035}{17474}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1322063929}-10035}{34948}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10035/17474)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1397}{16966}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1153332233}-1397}{33932}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1397/16966)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1440}{389}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{389} \\left(\\sqrt{669721}-720\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1440/389)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64167 \\pmod{88}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(64167 % 88)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23270)$.", + "Output Answer": [ + "$8544$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23270))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4198 \\pmod{73}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(4198 % 73)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30753)$.", + "Output Answer": [ + "$19008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30753))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54825 \\pmod{60}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(54825 % 60)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9321}{14272}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{901640977}-9321}{28544}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9321/14272)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-110$ is divisible by $-5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-110 % -5 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $955x \\equiv 1 \\pmod{1232}$.", + "Output Answer": [ + "$467$" + ], + "Output Program": [ + "print(pow(955, -1, 1232))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6560}{3473}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{22820129}-3280}{3473}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6560/3473)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1633x \\equiv 1 \\pmod{2194}$.", + "Output Answer": [ + "$1799$" + ], + "Output Program": [ + "print(pow(1633, -1, 2194))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $366$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(366 % -10 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 7 \\pmod{9}$", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "constraints = (9, 14), (7, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (7, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 14), (7, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $698$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(698 % -18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{25}{182}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{364} \\left(\\sqrt{133121}-25\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25/182)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-12298$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-12298 % -26 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{19}$\n$x \\equiv 16 \\pmod{18}$\n$x \\equiv 17 \\pmod{13}$\n$x \\equiv 4 \\pmod{10}$", + "Output Answer": [ + "$19114$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 19), (16, 18), (17, 13), (4, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 19), (16, 18), (17, 13), (4, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10008)$.", + "Output Answer": [ + "$3312$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10008))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $181^m \\equiv 1 \\pmod{220}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(181, 220))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{868,189\\}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "import math\n\nvalues = 868, 189\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-803,701,582\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -803, 701, 582\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $293x \\equiv 1 \\pmod{312}$.", + "Output Answer": [ + "$197$" + ], + "Output Program": [ + "print(pow(293, -1, 312))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $75288$.", + "Output Answer": [ + "$2^3\\cdot 3^1\\cdot 3137^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(75288))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $627^m \\equiv 1 \\pmod{776}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(627, 776))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $34739$.", + "Output Answer": [ + "$\\{6,10,14,18,19,23,24,26,29,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(34739):\n if len(roots) == 10: break\n if gcd(a, 34739) == 1 and is_primitive_root(a, 34739):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $171^m \\equiv 1 \\pmod{515}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(171, 515))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{33650}{22147}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{773570234}-16825}{22147}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33650/22147)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $222^m \\equiv 1 \\pmod{967}$.", + "Output Answer": [ + "$161$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(222, 967))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-2142$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2142 % -27 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71179 \\pmod{70}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(71179 % 70)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2171}{532}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5845337}-2171}{1064}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2171/532)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $49x \\equiv 1 \\pmod{482}$.", + "Output Answer": [ + "$423$" + ], + "Output Program": [ + "print(pow(49, -1, 482))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $220$ to base $20$.", + "Output Answer": [ + "$\\text{b0}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 220\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9585}{5431}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{209855269}-9585}{10862}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9585/5431)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.332$ to base $2$.", + "Output Answer": [ + "$0.01010100111111011111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.332\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{20}$\n$x \\equiv 13 \\pmod{18}$", + "Output Answer": [ + "$157$" + ], + "Output Program": [ + "constraints = (17, 20), (13, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 20), (13, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7867)$.", + "Output Answer": [ + "$7866$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7867))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-688,644\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -688, 644\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n6739", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6739))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-4473$ is divisible by $21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4473 % 21 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{116,376,-724\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = 116, 376, -724\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{19}$\n$x \\equiv 19 \\pmod{5}$\n$x \\equiv 16 \\pmod{17}$\n$x \\equiv 19 \\pmod{12}$", + "Output Answer": [ + "$8839$" + ], + "Output Program": [ + "constraints = (4, 19), (19, 5), (16, 17), (19, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 19), (19, 5), (16, 17), (19, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 19), (19, 5), (16, 17), (19, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33010)$.", + "Output Answer": [ + "$13200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33010))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $445$ to base $31$.", + "Output Answer": [ + "$\\text{eb}_{31}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 31\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 445\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{930,934\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 930, 934\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{259,399,-442\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 259, 399, -442\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{650,652\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 650, 652\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{670,323,-344\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 670, 323, -344\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $485^m \\equiv 1 \\pmod{722}$.", + "Output Answer": [ + "$342$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(485, 722))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $14^m \\equiv 1 \\pmod{81}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(14, 81))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1200}{1199}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1797601}-600}{1199}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1200/1199)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-364$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-364 % 8 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30556)$.", + "Output Answer": [ + "$15276$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30556))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2178^602 \\pmod{2486}$.", + "Output Answer": [ + "$1936$" + ], + "Output Program": [ + "print(pow(2178, 602, 2486))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n68881", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(68881))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29952)$.", + "Output Answer": [ + "$9216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29952))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{941}{2127}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18981997}-941}{4254}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(941/2127)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,1\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 2, 1\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 2 \\pmod{19}$", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "constraints = (14, 17), (2, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 17), (2, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (2, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $39x \\equiv 1 \\pmod{86}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "print(pow(39, -1, 86))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-32043$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-32043 % 33 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35574 \\pmod{66}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(35574 % 66)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{7737}{2797}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{91154005}-7737}{5594}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7737/2797)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n35897", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(35897))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44353)$.", + "Output Answer": [ + "$41728$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44353))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11510 \\pmod{34}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(11510 % 34)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n19077", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(19077))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-148$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-148 % -21 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1041^309 \\pmod{1586}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(pow(1041, 309, 1586))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $41^447 \\pmod{648}$.", + "Output Answer": [ + "$521$" + ], + "Output Program": [ + "print(pow(41, 447, 648))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{12477}{2566}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{182012953}-12477}{5132}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12477/2566)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5500}{7119}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{58242661}-2750}{7119}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5500/7119)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{19}$\n$x \\equiv 3 \\pmod{13}$\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$1069$" + ], + "Output Program": [ + "constraints = (5, 19), (3, 13), (13, 11), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 19), (3, 13), (13, 11), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1082x \\equiv 1 \\pmod{1085}$.", + "Output Answer": [ + "$723$" + ], + "Output Program": [ + "print(pow(1082, -1, 1085))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $49445$.", + "Output Answer": [ + "$5^1\\cdot 11^1\\cdot 29^1\\cdot 31^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(49445))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $726$ is divisible by $-6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(726 % -6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1065^2339 \\pmod{2856}$.", + "Output Answer": [ + "$1569$" + ], + "Output Program": [ + "print(pow(1065, 2339, 2856))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{77,681\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 77, 681\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $22079$.", + "Output Answer": [ + "$\\{7,19,21,26,28,29,31,35,38,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(22079):\n if len(roots) == 10: break\n if gcd(a, 22079) == 1 and is_primitive_root(a, 22079):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58412 \\pmod{23}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(58412 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{15}$\n$x \\equiv 13 \\pmod{19}$", + "Output Answer": [ + "$260$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 15), (13, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 15), (13, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 15), (13, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{356,893\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 356, 893\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1324^1777 \\pmod{2974}$.", + "Output Answer": [ + "$574$" + ], + "Output Program": [ + "print(pow(1324, 1777, 2974))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-120,-42\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -120, -42\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $16$ is divisible by $3$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(16 % 3 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $958^500 \\pmod{1048}$.", + "Output Answer": [ + "$768$" + ], + "Output Program": [ + "print(pow(958, 500, 1048))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7248)$.", + "Output Answer": [ + "$2400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7248))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{257,-276,588\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 257, -276, 588\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{7550}{3923}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{29640554}-3775}{3923}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7550/3923)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-919,-307\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -919, -307\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1041)$.", + "Output Answer": [ + "$692$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1041))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-748,-118\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -748, -118\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $950^167 \\pmod{1066}$.", + "Output Answer": [ + "$222$" + ], + "Output Program": [ + "print(pow(950, 167, 1066))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{6}$\n$x \\equiv 13 \\pmod{19}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 6), (13, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 6), (13, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 6), (13, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{9}$\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 18 \\pmod{17}$", + "Output Answer": [ + "$868$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 9), (10, 13), (18, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 9), (10, 13), (18, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 9), (10, 13), (18, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{8}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "constraints = (17, 8), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 8), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 8), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $31088$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(31088 % 29 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $360$ to base $15$.", + "Output Answer": [ + "$190_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 360\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18277)$.", + "Output Answer": [ + "$15624$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18277))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $125^m \\equiv 1 \\pmod{304}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(125, 304))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $536x \\equiv 1 \\pmod{575}$.", + "Output Answer": [ + "$516$" + ], + "Output Program": [ + "print(pow(536, -1, 575))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-967$ is divisible by $45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-967 % 45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9307)$.", + "Output Answer": [ + "$9040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9307))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $32^m \\equiv 1 \\pmod{935}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(32, 935))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $66073$.", + "Output Answer": [ + "$7^1\\cdot 9439^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(66073))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1558$ is divisible by $32$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1558 % 32 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33003)$.", + "Output Answer": [ + "$20736$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33003))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n28153", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(28153))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58012 \\pmod{71}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(58012 % 71)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3098}{2661}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9480322}-1549}{2661}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3098/2661)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $276x \\equiv 1 \\pmod{1309}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "print(pow(276, -1, 1309))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2409^461 \\pmod{2850}$.", + "Output Answer": [ + "$459$" + ], + "Output Program": [ + "print(pow(2409, 461, 2850))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{217,983,928\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 217, 983, 928\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $809^1336 \\pmod{2342}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(809, 1336, 2342))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{11}$\n$x \\equiv 15 \\pmod{13}$\n$x \\equiv 8 \\pmod{2}$\n$x \\equiv 2 \\pmod{12}$", + "Output Answer": [ + "$314$" + ], + "Output Program": [ + "constraints = (17, 11), (15, 13), (8, 2), (2, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 11), (15, 13), (8, 2), (2, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.62$ to base $24$.", + "Output Answer": [ + "$\\text{0.el2l}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.62\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $425x \\equiv 1 \\pmod{1787}$.", + "Output Answer": [ + "$534$" + ], + "Output Program": [ + "print(pow(425, -1, 1787))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $846^2091 \\pmod{1321}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(846, 2091, 1321))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1080^1979 \\pmod{1646}$.", + "Output Answer": [ + "$664$" + ], + "Output Program": [ + "print(pow(1080, 1979, 1646))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-477,-696\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -477, -696\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $49x \\equiv 1 \\pmod{142}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(pow(49, -1, 142))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $669^m \\equiv 1 \\pmod{700}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(669, 700))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{71,-585\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 71, -585\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $4^m \\equiv 1 \\pmod{773}$.", + "Output Answer": [ + "$386$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(4, 773))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $29762$.", + "Output Answer": [ + "$2^1\\cdot 23^1\\cdot 647^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(29762))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85539 \\pmod{63}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(85539 % 63)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $9102$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 37^1\\cdot 41^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(9102))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90502 \\pmod{95}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(90502 % 95)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $839$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(839 % -21 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n65927", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65927))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38611 \\pmod{78}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(38611 % 78)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{959,-94\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 959, -94\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1124$ to base $26$.", + "Output Answer": [ + "$\\text{1h6}_{26}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 26\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1124\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n35525", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(35525))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12513)$.", + "Output Answer": [ + "$8064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12513))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-826,532,499\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -826, 532, 499\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1527$ to base $20$.", + "Output Answer": [ + "$\\text{3g7}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1527\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8306)$.", + "Output Answer": [ + "$4152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8306))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $585^m \\equiv 1 \\pmod{842}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(585, 842))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $53774$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(53774 % 46 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{17}$\n$x \\equiv 11 \\pmod{2}$\n$x \\equiv 6 \\pmod{3}$", + "Output Answer": [ + "$87$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 17), (11, 2), (6, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 17), (11, 2), (6, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 17), (11, 2), (6, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2100020_3$ to base 10.", + "Output Answer": [ + "$1707$" + ], + "Output Program": [ + "n = '2100020'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n57489", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(57489))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{540,322\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 540, 322\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $479x \\equiv 1 \\pmod{1718}$.", + "Output Answer": [ + "$269$" + ], + "Output Program": [ + "print(pow(479, -1, 1718))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n16789", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(16789))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73889 \\pmod{53}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(73889 % 53)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $11970$ is divisible by $19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(11970 % 19 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $23^m \\equiv 1 \\pmod{774}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(23, 774))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 9 \\pmod{12}$", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "constraints = (0, 7), (9, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (0, 7), (9, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (9, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.99$ to base $5$.", + "Output Answer": [ + "$0.443333334_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.99\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{470}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 470))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47202)$.", + "Output Answer": [ + "$15732$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47202))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36299)$.", + "Output Answer": [ + "$36298$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36299))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $932x \\equiv 1 \\pmod{1303}$.", + "Output Answer": [ + "$1159$" + ], + "Output Program": [ + "print(pow(932, -1, 1303))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1321x \\equiv 1 \\pmod{1575}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(pow(1321, -1, 1575))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3623}{702}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{15097345}-3623}{1404}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3623/702)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $63^m \\equiv 1 \\pmod{167}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(63, 167))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-140$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-140 % 39 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69560 \\pmod{23}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(69560 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{796,186\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 796, 186\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{877,-632\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 877, -632\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-24048$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-24048 % -36 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7934$.", + "Output Answer": [ + "$\\{13,17,21,33,35,37,55,61,67,87\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7934):\n if len(roots) == 10: break\n if gcd(a, 7934) == 1 and is_primitive_root(a, 7934):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 9 \\pmod{3}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (10, 8), (9, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 8), (9, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 8), (9, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8669$.", + "Output Answer": [ + "$\\{2,3,7,8,10,12,15,18,22,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8669):\n if len(roots) == 10: break\n if gcd(a, 8669) == 1 and is_primitive_root(a, 8669):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n76483", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76483))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4156}{703}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{703} \\left(\\sqrt{4812293}-2078\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4156/703)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4847}{23572}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2246050145}-4847}{47144}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4847/23572)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39309 \\pmod{54}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(39309 % 54)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53394 \\pmod{64}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(53394 % 64)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $105360$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(105360 % -48 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-4004$ is divisible by $13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4004 % 13 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $780$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(780 % 12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30586)$.", + "Output Answer": [ + "$14880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30586))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 8 \\pmod{8}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (6, 6), (3, 3), (8, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (3, 3), (8, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1641^551 \\pmod{2085}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(pow(1641, 551, 2085))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19531 \\pmod{68}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(19531 % 68)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $439^m \\equiv 1 \\pmod{804}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(439, 804))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{24719}{28546}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{154821017}-24719}{57092}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24719/28546)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n28625", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(28625))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26220)$.", + "Output Answer": [ + "$6336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26220))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $540^m \\equiv 1 \\pmod{749}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(540, 749))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $26713$.", + "Output Answer": [ + "$\\{10,20,23,26,34,38,39,45,46,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(26713):\n if len(roots) == 10: break\n if gcd(a, 26713) == 1 and is_primitive_root(a, 26713):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30248 \\pmod{73}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(30248 % 73)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-487,291,304\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -487, 291, 304\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1690^169 \\pmod{2983}$.", + "Output Answer": [ + "$170$" + ], + "Output Program": [ + "print(pow(1690, 169, 2983))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40513 \\pmod{78}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(40513 % 78)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $145x \\equiv 1 \\pmod{816}$.", + "Output Answer": [ + "$529$" + ], + "Output Program": [ + "print(pow(145, -1, 816))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n34251", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(34251))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1442^1797 \\pmod{2579}$.", + "Output Answer": [ + "$639$" + ], + "Output Program": [ + "print(pow(1442, 1797, 2579))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6013}{10282}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{459034265}-6013}{20564}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6013/10282)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $6846$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(6846 % 24 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{9}$\n$x \\equiv 18 \\pmod{4}$\n$x \\equiv 14 \\pmod{20}$", + "Output Answer": [ + "$134$" + ], + "Output Program": [ + "constraints = (8, 9), (18, 4), (14, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 9), (18, 4), (14, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{25165}{6824}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{819545129}-25165}{13648}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25165/6824)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n26155", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26155))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{12}$\n$x \\equiv 15 \\pmod{13}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 12), (15, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 12), (15, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 12), (15, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-139,-309\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -139, -309\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-32805$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-32805 % -45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1203^858 \\pmod{1991}$.", + "Output Answer": [ + "$306$" + ], + "Output Program": [ + "print(pow(1203, 858, 1991))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $90^209 \\pmod{2490}$.", + "Output Answer": [ + "$990$" + ], + "Output Program": [ + "print(pow(90, 209, 2490))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $914$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(914 % -44 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1308^1101 \\pmod{1555}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(pow(1308, 1101, 1555))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8084)$.", + "Output Answer": [ + "$3864$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8084))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{528,253\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 528, 253\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{34973}{1798}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1236041945}-34973}{3596}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34973/1798)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $247^m \\equiv 1 \\pmod{278}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(247, 278))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{2,-3\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = 2, -3\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1817^1368 \\pmod{2509}$.", + "Output Answer": [ + "$1587$" + ], + "Output Program": [ + "print(pow(1817, 1368, 2509))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $119^m \\equiv 1 \\pmod{583}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(119, 583))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-215$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-215 % -15 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $177^1312 \\pmod{2174}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(pow(177, 1312, 2174))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{15821}{1348}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{257572457}-15821}{2696}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15821/1348)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2459^1804 \\pmod{2529}$.", + "Output Answer": [ + "$1159$" + ], + "Output Program": [ + "print(pow(2459, 1804, 2529))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{139,-545,289\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 139, -545, 289\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $346^m \\equiv 1 \\pmod{467}$.", + "Output Answer": [ + "$466$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(346, 467))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-729,802\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -729, 802\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $189^m \\equiv 1 \\pmod{326}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(189, 326))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2214$ to base $16$.", + "Output Answer": [ + "$\\text{8a6}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2214\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{751,885\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 751, 885\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{8}$\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 3 \\pmod{7}$\n$x \\equiv 15 \\pmod{6}$", + "Output Answer": [ + "$129$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 8), (12, 3), (3, 7), (15, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 8), (12, 3), (3, 7), (15, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $175^m \\equiv 1 \\pmod{317}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(175, 317))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 17 \\pmod{6}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "constraints = (5, 4), (17, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 4), (17, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-803,860\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -803, 860\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2200}{13}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{13} \\left(\\sqrt{1210169}-1100\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2200/13)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $133^m \\equiv 1 \\pmod{185}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(133, 185))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{15}$\n$x \\equiv 14 \\pmod{11}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 15), (14, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 15), (14, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 15), (14, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $571^m \\equiv 1 \\pmod{836}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(571, 836))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{959}{21668}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1878928577}-959}{43336}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(959/21668)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $219^m \\equiv 1 \\pmod{718}$.", + "Output Answer": [ + "$179$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(219, 718))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{5860}{4759}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{31232981}-2930}{4759}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5860/4759)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $570^m \\equiv 1 \\pmod{707}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(570, 707))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 7 \\pmod{4}$\n$x \\equiv 9 \\pmod{11}$\n$x \\equiv 13 \\pmod{3}$", + "Output Answer": [ + "$427$" + ], + "Output Program": [ + "constraints = (7, 7), (7, 4), (9, 11), (13, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 7), (7, 4), (9, 11), (13, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 7), (7, 4), (9, 11), (13, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n24031", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24031))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $44^m \\equiv 1 \\pmod{281}$.", + "Output Answer": [ + "$280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(44, 281))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8728}{9289}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{105330017}-4364}{9289}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8728/9289)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $223x \\equiv 1 \\pmod{248}$.", + "Output Answer": [ + "$119$" + ], + "Output Program": [ + "print(pow(223, -1, 248))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{10}$\n$x \\equiv 0 \\pmod{10}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 10), (0, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 10), (0, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $44$ is divisible by $1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(44 % 1 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{7,876,-451\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 7, 876, -451\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36457)$.", + "Output Answer": [ + "$36456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36457))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $81541$.", + "Output Answer": [ + "$73^1\\cdot 1117^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(81541))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50464 \\pmod{47}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(50464 % 47)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24329 \\pmod{70}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(24329 % 70)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21043)$.", + "Output Answer": [ + "$19120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21043))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $48407$.", + "Output Answer": [ + "$\\{5,7,10,13,14,15,20,21,26,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(48407):\n if len(roots) == 10: break\n if gcd(a, 48407) == 1 and is_primitive_root(a, 48407):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $83^m \\equiv 1 \\pmod{313}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(83, 313))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{16}$\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 9 \\pmod{6}$", + "Output Answer": [ + "$165$" + ], + "Output Program": [ + "constraints = (5, 16), (5, 5), (9, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 16), (5, 5), (9, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24629)$.", + "Output Answer": [ + "$22380$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24629))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-888,-362,297\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -888, -362, 297\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44978)$.", + "Output Answer": [ + "$21924$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44978))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33837 \\pmod{78}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(33837 % 78)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{17}$\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 20 \\pmod{11}$", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 17), (15, 9), (20, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 17), (15, 9), (20, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 17), (15, 9), (20, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{13437}{6457}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{347324365}-13437}{12914}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13437/6457)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n1667", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1667))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{766}$.", + "Output Answer": [ + "$382$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 766))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1151^2058 \\pmod{1904}$.", + "Output Answer": [ + "$1233$" + ], + "Output Program": [ + "print(pow(1151, 2058, 1904))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $40182$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(40182 % 37 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2372^2365 \\pmod{2602}$.", + "Output Answer": [ + "$2006$" + ], + "Output Program": [ + "print(pow(2372, 2365, 2602))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $364^m \\equiv 1 \\pmod{375}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(364, 375))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{679,622\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 679, 622\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40152)$.", + "Output Answer": [ + "$11424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40152))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $115^m \\equiv 1 \\pmod{312}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(115, 312))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $468^m \\equiv 1 \\pmod{551}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(468, 551))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-263,99,184\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -263, 99, 184\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n64303", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64303))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{6}$\n$x \\equiv 20 \\pmod{15}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 6), (20, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 6), (20, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29974)$.", + "Output Answer": [ + "$12840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29974))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-772,-73\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -772, -73\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{486,736\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 486, 736\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80284 \\pmod{46}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(80284 % 46)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $553x \\equiv 1 \\pmod{668}$.", + "Output Answer": [ + "$273$" + ], + "Output Program": [ + "print(pow(553, -1, 668))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $33^m \\equiv 1 \\pmod{92}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(33, 92))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27978)$.", + "Output Answer": [ + "$9324$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27978))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $61562$.", + "Output Answer": [ + "$\\{29,31,51,53,61,67,69,83,87,89\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(61562):\n if len(roots) == 10: break\n if gcd(a, 61562) == 1 and is_primitive_root(a, 61562):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{75}{322}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{644} \\left(\\sqrt{420361}-75\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(75/322)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{17}$\n$x \\equiv 16 \\pmod{20}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$1316$" + ], + "Output Program": [ + "constraints = (7, 17), (16, 20), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 17), (16, 20), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{772,484\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 772, 484\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{12178}{11921}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{179186162}-6089}{11921}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12178/11921)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n70665", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70665))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 4 \\pmod{8}$\n$x \\equiv 17 \\pmod{13}$", + "Output Answer": [ + "$1460$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 15), (4, 8), (17, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 15), (4, 8), (17, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (5, 15), (4, 8), (17, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27922)$.", + "Output Answer": [ + "$13332$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27922))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $139^m \\equiv 1 \\pmod{188}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(139, 188))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2003}{6627}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{7187221}-2003}{13254}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2003/6627)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n60537", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60537))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $131x \\equiv 1 \\pmod{2022}$.", + "Output Answer": [ + "$1667$" + ], + "Output Program": [ + "print(pow(131, -1, 2022))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $211101_3$ to base 10.", + "Output Answer": [ + "$604$" + ], + "Output Program": [ + "n = '211101'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23165 \\pmod{37}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(23165 % 37)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1692^2339 \\pmod{2069}$.", + "Output Answer": [ + "$2043$" + ], + "Output Program": [ + "print(pow(1692, 2339, 2069))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $295x \\equiv 1 \\pmod{1161}$.", + "Output Answer": [ + "$1039$" + ], + "Output Program": [ + "print(pow(295, -1, 1161))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 14 \\pmod{16}$\n$x \\equiv 8 \\pmod{2}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "constraints = (12, 3), (14, 16), (8, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 3), (14, 16), (8, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-800,-715\\}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nvalues = -800, -715\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $46301$.", + "Output Answer": [ + "$\\{2,3,7,8,10,11,12,13,15,17\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(46301):\n if len(roots) == 10: break\n if gcd(a, 46301) == 1 and is_primitive_root(a, 46301):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $700x \\equiv 1 \\pmod{1119}$.", + "Output Answer": [ + "$673$" + ], + "Output Program": [ + "print(pow(700, -1, 1119))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $401^m \\equiv 1 \\pmod{424}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(401, 424))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $725^m \\equiv 1 \\pmod{728}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(725, 728))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8582)$.", + "Output Answer": [ + "$3672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8582))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1359^2007 \\pmod{2910}$.", + "Output Answer": [ + "$1359$" + ], + "Output Program": [ + "print(pow(1359, 2007, 2910))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $641^2376 \\pmod{2014}$.", + "Output Answer": [ + "$685$" + ], + "Output Program": [ + "print(pow(641, 2376, 2014))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{648,879\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 648, 879\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50058 \\pmod{26}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(50058 % 26)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{542,537\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 542, 537\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{14}$\n$x \\equiv 11 \\pmod{13}$\n$x \\equiv 9 \\pmod{20}$", + "Output Answer": [ + "$869$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 14), (11, 13), (9, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 14), (11, 13), (9, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $193x \\equiv 1 \\pmod{231}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "print(pow(193, -1, 231))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-24196$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-24196 % 46 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{4}$\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$168$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 4), (12, 13), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 4), (12, 13), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n63029", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63029))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $900$ is divisible by $-6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(900 % -6 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1131}{1072}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5875897}-1131}{2144}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1131/1072)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $389x \\equiv 1 \\pmod{1025}$.", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "print(pow(389, -1, 1025))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69300 \\pmod{72}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(69300 % 72)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44791)$.", + "Output Answer": [ + "$43792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44791))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $467x \\equiv 1 \\pmod{542}$.", + "Output Answer": [ + "$383$" + ], + "Output Program": [ + "print(pow(467, -1, 542))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.35222222_6$ to base 10.", + "Output Answer": [ + "$0.65$" + ], + "Output Program": [ + "n = '0.35222222'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 8 \\pmod{10}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$228$" + ], + "Output Program": [ + "constraints = (6, 6), (8, 10), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (8, 10), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24861)$.", + "Output Answer": [ + "$16572$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24861))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $9551$.", + "Output Answer": [ + "$\\{11,17,22,23,29,33,34,37,44,46\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(9551):\n if len(roots) == 10: break\n if gcd(a, 9551) == 1 and is_primitive_root(a, 9551):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n100933", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(100933))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-983,-499\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -983, -499\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25577)$.", + "Output Answer": [ + "$25576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25577))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $303^m \\equiv 1 \\pmod{364}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(303, 364))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{25427}{4570}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{730071929}-25427}{9140}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25427/4570)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69410 \\pmod{55}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(69410 % 55)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n20339", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(20339))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n5647", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5647))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{12167}{21598}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2013930305}-12167}{43196}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12167/21598)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74951 \\pmod{54}$.", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "print(74951 % 54)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-177$ is divisible by $-13$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-177 % -13 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24538)$.", + "Output Answer": [ + "$12268$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24538))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 4 \\pmod{8}$\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 0 \\pmod{12}$", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "constraints = (0, 20), (4, 8), (4, 2), (0, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 20), (4, 8), (4, 2), (0, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17271)$.", + "Output Answer": [ + "$10800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17271))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83729 \\pmod{93}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(83729 % 93)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1380^2031 \\pmod{2993}$.", + "Output Answer": [ + "$489$" + ], + "Output Program": [ + "print(pow(1380, 2031, 2993))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $136^220 \\pmod{146}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "print(pow(136, 220, 146))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $94305$.", + "Output Answer": [ + "$3^1\\cdot 5^1\\cdot 6287^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(94305))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17413)$.", + "Output Answer": [ + "$15820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17413))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73365 \\pmod{65}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(73365 % 65)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{13}$\n$x \\equiv 7 \\pmod{14}$\n$x \\equiv 2 \\pmod{9}$\n$x \\equiv 4 \\pmod{19}$", + "Output Answer": [ + "$6293$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 13), (7, 14), (2, 9), (4, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 13), (7, 14), (2, 9), (4, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 13), (7, 14), (2, 9), (4, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{4}$\n$x \\equiv 8 \\pmod{19}$", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "constraints = (11, 4), (8, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 4), (8, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 4), (8, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2159x \\equiv 1 \\pmod{2349}$.", + "Output Answer": [ + "$2213$" + ], + "Output Program": [ + "print(pow(2159, -1, 2349))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{932,-154\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 932, -154\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2097^1282 \\pmod{2302}$.", + "Output Answer": [ + "$2207$" + ], + "Output Program": [ + "print(pow(2097, 1282, 2302))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2709}{2626}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{34922185}-2709}{5252}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2709/2626)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1357x \\equiv 1 \\pmod{2032}$.", + "Output Answer": [ + "$581$" + ], + "Output Program": [ + "print(pow(1357, -1, 2032))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{446,61,-448\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 446, 61, -448\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n36527", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(36527))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1125x \\equiv 1 \\pmod{1162}$.", + "Output Answer": [ + "$157$" + ], + "Output Program": [ + "print(pow(1125, -1, 1162))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{254}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 254))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $639^201 \\pmod{1477}$.", + "Output Answer": [ + "$1450$" + ], + "Output Program": [ + "print(pow(639, 201, 1477))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1072^954 \\pmod{2928}$.", + "Output Answer": [ + "$2176$" + ], + "Output Program": [ + "print(pow(1072, 954, 2928))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67294 \\pmod{10}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(67294 % 10)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-434,423,-580\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -434, 423, -580\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $79x \\equiv 1 \\pmod{1064}$.", + "Output Answer": [ + "$431$" + ], + "Output Program": [ + "print(pow(79, -1, 1064))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $3778$.", + "Output Answer": [ + "$\\{3,7,11,15,19,27,35,37,39,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(3778):\n if len(roots) == 10: break\n if gcd(a, 3778) == 1 and is_primitive_root(a, 3778):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-678,-713\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -678, -713\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $676x \\equiv 1 \\pmod{963}$.", + "Output Answer": [ + "$406$" + ], + "Output Program": [ + "print(pow(676, -1, 963))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1576$ to base $34$.", + "Output Answer": [ + "$\\text{1cc}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1576\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $138x \\equiv 1 \\pmod{419}$.", + "Output Answer": [ + "$167$" + ], + "Output Program": [ + "print(pow(138, -1, 419))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{16}$\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 6 \\pmod{2}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "constraints = (2, 16), (16, 3), (6, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 16), (16, 3), (6, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35606)$.", + "Output Answer": [ + "$16848$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35606))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $3^m \\equiv 1 \\pmod{40}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(3, 40))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-564,-241,289\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -564, -241, 289\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $684$ to base $13$.", + "Output Answer": [ + "$408_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 684\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{17607}{1466}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{318603073}-17607}{2932}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17607/1466)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $672$ to base $9$.", + "Output Answer": [ + "$826_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 672\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{37147}{40928}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{8080304345}-37147}{81856}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37147/40928)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54219 \\pmod{52}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(54219 % 52)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $128^m \\equiv 1 \\pmod{231}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(128, 231))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $23^m \\equiv 1 \\pmod{559}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(23, 559))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $213x \\equiv 1 \\pmod{902}$.", + "Output Answer": [ + "$487$" + ], + "Output Program": [ + "print(pow(213, -1, 902))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2391^37 \\pmod{2612}$.", + "Output Answer": [ + "$799$" + ], + "Output Program": [ + "print(pow(2391, 37, 2612))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25357 \\pmod{10}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(25357 % 10)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2262^2071 \\pmod{2316}$.", + "Output Answer": [ + "$996$" + ], + "Output Program": [ + "print(pow(2262, 2071, 2316))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2496$ to base $34$.", + "Output Answer": [ + "$\\text{25e}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2496\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14359)$.", + "Output Answer": [ + "$14104$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14359))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{3}$\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "constraints = (19, 3), (10, 5), (7, 7), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 3), (10, 5), (7, 7), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $216x \\equiv 1 \\pmod{301}$.", + "Output Answer": [ + "$216$" + ], + "Output Program": [ + "print(pow(216, -1, 301))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27675)$.", + "Output Answer": [ + "$14400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27675))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1777}{6624}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{178667233}-1777}{13248}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1777/6624)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $181x \\equiv 1 \\pmod{2428}$.", + "Output Answer": [ + "$1489$" + ], + "Output Program": [ + "print(pow(181, -1, 2428))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $525x \\equiv 1 \\pmod{1346}$.", + "Output Answer": [ + "$241$" + ], + "Output Program": [ + "print(pow(525, -1, 1346))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1106}{1013}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1331978}-553}{1013}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1106/1013)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1037x \\equiv 1 \\pmod{1501}$.", + "Output Answer": [ + "$482$" + ], + "Output Program": [ + "print(pow(1037, -1, 1501))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $325x \\equiv 1 \\pmod{831}$.", + "Output Answer": [ + "$202$" + ], + "Output Program": [ + "print(pow(325, -1, 831))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 4 \\pmod{19}$", + "Output Answer": [ + "$2436$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 16), (6, 15), (4, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 16), (6, 15), (4, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 16), (6, 15), (4, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n54491", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54491))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2062^1467 \\pmod{2439}$.", + "Output Answer": [ + "$541$" + ], + "Output Program": [ + "print(pow(2062, 1467, 2439))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-5980$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5980 % 23 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $238^370 \\pmod{2837}$.", + "Output Answer": [ + "$1170$" + ], + "Output Program": [ + "print(pow(238, 370, 2837))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49672)$.", + "Output Answer": [ + "$21264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49672))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26004)$.", + "Output Answer": [ + "$7840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26004))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-48$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-48 % -3 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.07$ to base $16$.", + "Output Answer": [ + "$\\text{0.11eb8}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.07\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-5584$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5584 % 16 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $194^m \\equiv 1 \\pmod{321}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(194, 321))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $160x \\equiv 1 \\pmod{163}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(pow(160, -1, 163))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1098^1755 \\pmod{2799}$.", + "Output Answer": [ + "$1161$" + ], + "Output Program": [ + "print(pow(1098, 1755, 2799))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 19 \\pmod{7}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "constraints = (8, 11), (19, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (19, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (8, 11), (19, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{839}{8}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{16} \\left(\\sqrt{704177}-839\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(839/8)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $83x \\equiv 1 \\pmod{118}$.", + "Output Answer": [ + "$91$" + ], + "Output Program": [ + "print(pow(83, -1, 118))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-218,606\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -218, 606\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{759,764,-261\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 759, 764, -261\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{287,-794,-450\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 287, -794, -450\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $149^m \\equiv 1 \\pmod{195}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(149, 195))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9033 \\pmod{25}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(9033 % 25)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $429x \\equiv 1 \\pmod{1195}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(pow(429, -1, 1195))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $33x \\equiv 1 \\pmod{1241}$.", + "Output Answer": [ + "$1053$" + ], + "Output Program": [ + "print(pow(33, -1, 1241))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 4 \\pmod{15}$", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 7), (14, 13), (4, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 7), (14, 13), (4, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 7), (14, 13), (4, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-518,709\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -518, 709\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n13145", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(13145))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-782$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-782 % -27 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $92235$.", + "Output Answer": [ + "$3^1\\cdot 5^1\\cdot 11^1\\cdot 13^1\\cdot 43^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(92235))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{253,851\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 253, 851\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1285^1429 \\pmod{2351}$.", + "Output Answer": [ + "$427$" + ], + "Output Program": [ + "print(pow(1285, 1429, 2351))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49546)$.", + "Output Answer": [ + "$21228$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49546))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{8}$\n$x \\equiv 0 \\pmod{2}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "constraints = (20, 8), (0, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 8), (0, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $31496$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(31496 % -31 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1689^2392 \\pmod{1917}$.", + "Output Answer": [ + "$1215$" + ], + "Output Program": [ + "print(pow(1689, 2392, 1917))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1810}{1763}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3927194}-905}{1763}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1810/1763)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n75883", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(75883))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $899^1165 \\pmod{2030}$.", + "Output Answer": [ + "$899$" + ], + "Output Program": [ + "print(pow(899, 1165, 2030))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{419,-372\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 419, -372\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{341,84,746\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 341, 84, 746\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{37,814,-689\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 37, 814, -689\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1192^942 \\pmod{2532}$.", + "Output Answer": [ + "$2392$" + ], + "Output Program": [ + "print(pow(1192, 942, 2532))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{1,-5,-4\\}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nvalues = 1, -5, -4\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{32,584\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 32, 584\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n91293", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(91293))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29709)$.", + "Output Answer": [ + "$19800$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29709))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $871x \\equiv 1 \\pmod{1472}$.", + "Output Answer": [ + "$1303$" + ], + "Output Program": [ + "print(pow(871, -1, 1472))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $53x \\equiv 1 \\pmod{1358}$.", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "print(pow(53, -1, 1358))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67800 \\pmod{48}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(67800 % 48)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3060)$.", + "Output Answer": [ + "$768$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3060))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-39585$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-39585 % 29 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93822 \\pmod{36}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(93822 % 36)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29136)$.", + "Output Answer": [ + "$9696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29136))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $11x \\equiv 1 \\pmod{93}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(11, -1, 93))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 14 \\pmod{13}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 5), (14, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 5), (14, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 5), (14, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1837^35 \\pmod{1982}$.", + "Output Answer": [ + "$1653$" + ], + "Output Program": [ + "print(pow(1837, 35, 1982))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $466^1907 \\pmod{1586}$.", + "Output Answer": [ + "$370$" + ], + "Output Program": [ + "print(pow(466, 1907, 1586))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $904x \\equiv 1 \\pmod{1289}$.", + "Output Answer": [ + "$683$" + ], + "Output Program": [ + "print(pow(904, -1, 1289))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37679)$.", + "Output Answer": [ + "$36720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37679))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1447$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1447 % 31 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{935}{9}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{18} \\left(\\sqrt{874549}-935\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(935/9)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{16471}{12218}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{868411937}-16471}{24436}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16471/12218)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $43x \\equiv 1 \\pmod{756}$.", + "Output Answer": [ + "$211$" + ], + "Output Program": [ + "print(pow(43, -1, 756))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $263^m \\equiv 1 \\pmod{656}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(263, 656))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n51749", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51749))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45553)$.", + "Output Answer": [ + "$45552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45553))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-2,5\\}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "import math\n\nvalues = -2, 5\nprint(math.lcm(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{757,-928,194\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 757, -928, 194\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{16172}{15077}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{11707973}-8086}{15077}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16172/15077)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38831)$.", + "Output Answer": [ + "$34272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38831))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-70148$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-70148 % -38 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $793$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(793 % 39 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{187}{175}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{350} \\left(\\sqrt{157469}-187\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(187/175)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $240$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(240 % -46 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21397 \\pmod{82}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(21397 % 82)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85924 \\pmod{33}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(85924 % 33)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33073 \\pmod{24}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(33073 % 24)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40059)$.", + "Output Answer": [ + "$26700$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40059))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87566 \\pmod{60}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(87566 % 60)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1567^1958 \\pmod{2020}$.", + "Output Answer": [ + "$1889$" + ], + "Output Program": [ + "print(pow(1567, 1958, 2020))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{766,-356\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 766, -356\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $541^1699 \\pmod{787}$.", + "Output Answer": [ + "$363$" + ], + "Output Program": [ + "print(pow(541, 1699, 787))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $551x \\equiv 1 \\pmod{606}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(551, -1, 606))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1395^2479 \\pmod{1690}$.", + "Output Answer": [ + "$225$" + ], + "Output Program": [ + "print(pow(1395, 2479, 1690))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $1^m \\equiv 1 \\pmod{381}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(1, 381))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{13561}{14251}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{39850589}-13561}{28502}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13561/14251)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{14}$\n$x \\equiv 13 \\pmod{19}$", + "Output Answer": [ + "$260$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 14), (13, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 14), (13, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 14), (13, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16460 \\pmod{27}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(16460 % 27)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $170^1245 \\pmod{1896}$.", + "Output Answer": [ + "$1256$" + ], + "Output Program": [ + "print(pow(170, 1245, 1896))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26094 \\pmod{27}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(26094 % 27)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $237x \\equiv 1 \\pmod{1217}$.", + "Output Answer": [ + "$190$" + ], + "Output Program": [ + "print(pow(237, -1, 1217))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{221,106\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 221, 106\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $95821$.", + "Output Answer": [ + "$11^1\\cdot 31^1\\cdot 281^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(95821))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $185x \\equiv 1 \\pmod{1072}$.", + "Output Answer": [ + "$649$" + ], + "Output Program": [ + "print(pow(185, -1, 1072))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{14}$\n$x \\equiv 19 \\pmod{19}$", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 14), (19, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 14), (19, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 14), (19, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $41^m \\equiv 1 \\pmod{147}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(41, 147))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15678)$.", + "Output Answer": [ + "$4752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15678))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n56897", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(56897))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $126^m \\equiv 1 \\pmod{493}$.", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(126, 493))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{6863}{8701}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{349930373}-6863}{17402}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6863/8701)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60929 \\pmod{40}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(60929 % 40)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9394)$.", + "Output Answer": [ + "$3600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9394))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{10}$\n$x \\equiv 7 \\pmod{7}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 10), (7, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 10), (7, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (10, 10), (7, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $11675$.", + "Output Answer": [ + "$5^2\\cdot 467^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(11675))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2172 \\pmod{42}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(2172 % 42)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31987)$.", + "Output Answer": [ + "$30856$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31987))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1942}{2027}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5051570}-971}{2027}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1942/2027)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{342,95\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 342, 95\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1498^1043 \\pmod{2031}$.", + "Output Answer": [ + "$1768$" + ], + "Output Program": [ + "print(pow(1498, 1043, 2031))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29119)$.", + "Output Answer": [ + "$28296$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29119))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{10}$\n$x \\equiv 13 \\pmod{7}$\n$x \\equiv 16 \\pmod{13}$", + "Output Answer": [ + "$510$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 10), (13, 7), (16, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 10), (13, 7), (16, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 10), (13, 7), (16, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $59^m \\equiv 1 \\pmod{94}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(59, 94))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $514^1813 \\pmod{2444}$.", + "Output Answer": [ + "$1580$" + ], + "Output Program": [ + "print(pow(514, 1813, 2444))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{30,900\\}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "import math\n\nvalues = 30, 900\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61235 \\pmod{23}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(61235 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67724 \\pmod{70}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(67724 % 70)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 7 \\pmod{10}$\n$x \\equiv 7 \\pmod{4}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (3, 4), (7, 10), (7, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 4), (7, 10), (7, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $143x \\equiv 1 \\pmod{615}$.", + "Output Answer": [ + "$572$" + ], + "Output Program": [ + "print(pow(143, -1, 615))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35905)$.", + "Output Answer": [ + "$27888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35905))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1321^396 \\pmod{1846}$.", + "Output Answer": [ + "$651$" + ], + "Output Program": [ + "print(pow(1321, 396, 1846))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{100,-536,160\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = 100, -536, 160\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 16 \\pmod{16}$", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 7), (16, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 7), (16, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 7), (16, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $208^2063 \\pmod{350}$.", + "Output Answer": [ + "$262$" + ], + "Output Program": [ + "print(pow(208, 2063, 350))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n79557", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(79557))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15543)$.", + "Output Answer": [ + "$9360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15543))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 8 \\pmod{20}$\n$x \\equiv 8 \\pmod{4}$", + "Output Answer": [ + "$188$" + ], + "Output Program": [ + "constraints = (1, 11), (8, 20), (8, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 11), (8, 20), (8, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{21,-694,-97\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 21, -694, -97\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1483^2286 \\pmod{2821}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(1483, 2286, 2821))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62550 \\pmod{37}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(62550 % 37)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $36229$.", + "Output Answer": [ + "$\\{2,6,10,11,14,19,24,29,31,32\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(36229):\n if len(roots) == 10: break\n if gcd(a, 36229) == 1 and is_primitive_root(a, 36229):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-49$ is divisible by $2$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-49 % 2 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $666^1779 \\pmod{2212}$.", + "Output Answer": [ + "$848$" + ], + "Output Program": [ + "print(pow(666, 1779, 2212))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1253x \\equiv 1 \\pmod{1306}$.", + "Output Answer": [ + "$961$" + ], + "Output Program": [ + "print(pow(1253, -1, 1306))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 51326 \\pmod{81}$.", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "print(51326 % 81)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1389x \\equiv 1 \\pmod{1664}$.", + "Output Answer": [ + "$357$" + ], + "Output Program": [ + "print(pow(1389, -1, 1664))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $635^m \\equiv 1 \\pmod{648}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(635, 648))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $426x \\equiv 1 \\pmod{907}$.", + "Output Answer": [ + "$841$" + ], + "Output Program": [ + "print(pow(426, -1, 907))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14781)$.", + "Output Answer": [ + "$9072$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14781))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{676,-659\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 676, -659\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5916)$.", + "Output Answer": [ + "$1792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5916))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n59661", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59661))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-2960$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2960 % -10 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4399}{3518}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{68856497}-4399}{7036}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4399/3518)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23891)$.", + "Output Answer": [ + "$20472$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23891))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1134$ is divisible by $-48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1134 % -48 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $719x \\equiv 1 \\pmod{1288}$.", + "Output Answer": [ + "$1039$" + ], + "Output Program": [ + "print(pow(719, -1, 1288))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{37186}{9001}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{17068706}-18593}{9001}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37186/9001)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n74071", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(74071))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{28333}{41990}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7855399289}-28333}{83980}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(28333/41990)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74297 \\pmod{90}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(74297 % 90)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-156,799,440\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -156, 799, 440\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-116,984\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -116, 984\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22941)$.", + "Output Answer": [ + "$15288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22941))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1306x \\equiv 1 \\pmod{2187}$.", + "Output Answer": [ + "$1693$" + ], + "Output Program": [ + "print(pow(1306, -1, 2187))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1530^1686 \\pmod{2508}$.", + "Output Answer": [ + "$672$" + ], + "Output Program": [ + "print(pow(1530, 1686, 2508))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2132^1907 \\pmod{2426}$.", + "Output Answer": [ + "$1370$" + ], + "Output Program": [ + "print(pow(2132, 1907, 2426))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-716,869\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -716, 869\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1726$ to base $30$.", + "Output Answer": [ + "$\\text{1rg}_{30}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 30\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1726\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1456}{639}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{639} \\left(\\sqrt{938305}-728\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1456/639)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $1484$ is divisible by $16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1484 % 16 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{34948}{11853}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{445834285}-17474}{11853}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34948/11853)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{12}$\n$x \\equiv 5 \\pmod{19}$", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "constraints = (4, 12), (5, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 12), (5, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 12), (5, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $56^868 \\pmod{771}$.", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "print(pow(56, 868, 771))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1733x \\equiv 1 \\pmod{1754}$.", + "Output Answer": [ + "$167$" + ], + "Output Program": [ + "print(pow(1733, -1, 1754))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $943x \\equiv 1 \\pmod{1439}$.", + "Output Answer": [ + "$1204$" + ], + "Output Program": [ + "print(pow(943, -1, 1439))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{426,601,992\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 426, 601, 992\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37696 \\pmod{24}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(37696 % 24)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23095)$.", + "Output Answer": [ + "$17760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23095))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{5}$\n$x \\equiv 20 \\pmod{19}$", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 5), (20, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 5), (20, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 5), (20, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $48823$.", + "Output Answer": [ + "$\\{5,6,11,20,21,22,24,26,37,40\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(48823):\n if len(roots) == 10: break\n if gcd(a, 48823) == 1 and is_primitive_root(a, 48823):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-55370$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-55370 % -35 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 13 \\pmod{17}$", + "Output Answer": [ + "$523$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 11), (3, 8), (13, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 11), (3, 8), (13, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 11), (3, 8), (13, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $8406$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8406 % -18 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14882)$.", + "Output Answer": [ + "$6372$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14882))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{176,319\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 176, 319\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1895^786 \\pmod{2364}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(1895, 786, 2364))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-37,-144\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -37, -144\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-5,878,-192\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -5, 878, -192\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{20258}{8415}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{173408866}-10129}{8415}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20258/8415)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $75x \\equiv 1 \\pmod{1012}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(pow(75, -1, 1012))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{16}$\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 8 \\pmod{17}$\n$x \\equiv 6 \\pmod{14}$", + "Output Answer": [ + "$16260$" + ], + "Output Program": [ + "constraints = (20, 16), (15, 19), (8, 17), (6, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 16), (15, 19), (8, 17), (6, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-580,-337\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -580, -337\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1517^629 \\pmod{2200}$.", + "Output Answer": [ + "$197$" + ], + "Output Program": [ + "print(pow(1517, 629, 2200))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-912,-852,-348\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = -912, -852, -348\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1117x \\equiv 1 \\pmod{1926}$.", + "Output Answer": [ + "$469$" + ], + "Output Program": [ + "print(pow(1117, -1, 1926))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $59^1942 \\pmod{1386}$.", + "Output Answer": [ + "$445$" + ], + "Output Program": [ + "print(pow(59, 1942, 1386))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{7}$\n$x \\equiv 15 \\pmod{8}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 7), (15, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 7), (15, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 7), (15, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{19689}{6590}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{561369121}-19689}{13180}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19689/6590)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{16}$\n$x \\equiv 11 \\pmod{13}$\n$x \\equiv 8 \\pmod{15}$\n$x \\equiv 15 \\pmod{11}$", + "Output Answer": [ + "$8903$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 16), (11, 13), (8, 15), (15, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 16), (11, 13), (8, 15), (15, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 16), (11, 13), (8, 15), (15, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19349)$.", + "Output Answer": [ + "$17580$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19349))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4736)$.", + "Output Answer": [ + "$2304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4736))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-487,-383\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -487, -383\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{198,-345\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 198, -345\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-509,113,501\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -509, 113, 501\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24036)$.", + "Output Answer": [ + "$8008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24036))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1412x \\equiv 1 \\pmod{2087}$.", + "Output Answer": [ + "$303$" + ], + "Output Program": [ + "print(pow(1412, -1, 2087))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1950^2024 \\pmod{2753}$.", + "Output Answer": [ + "$1812$" + ], + "Output Program": [ + "print(pow(1950, 2024, 2753))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9162)$.", + "Output Answer": [ + "$3048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9162))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $239^m \\equiv 1 \\pmod{364}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(239, 364))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $583^m \\equiv 1 \\pmod{879}$.", + "Output Answer": [ + "$292$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(583, 879))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{16}$\n$x \\equiv 18 \\pmod{15}$", + "Output Answer": [ + "$123$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 16), (18, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 16), (18, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 16), (18, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14234)$.", + "Output Answer": [ + "$6460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14234))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1149$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1149 % 25 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 12 \\pmod{3}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (9, 5), (12, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 5), (12, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 5), (12, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $56893$.", + "Output Answer": [ + "$\\{2,5,6,13,14,15,17,18,20,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(56893):\n if len(roots) == 10: break\n if gcd(a, 56893) == 1 and is_primitive_root(a, 56893):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-208,-20,19\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -208, -20, 19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-25020$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-25020 % -30 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2133^1371 \\pmod{2449}$.", + "Output Answer": [ + "$869$" + ], + "Output Program": [ + "print(pow(2133, 1371, 2449))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31269)$.", + "Output Answer": [ + "$17856$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31269))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2379^1103 \\pmod{2902}$.", + "Output Answer": [ + "$1573$" + ], + "Output Program": [ + "print(pow(2379, 1103, 2902))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-817,440\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -817, 440\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{4713}{4214}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{551737}-4713}{8428}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4713/4214)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $4^m \\equiv 1 \\pmod{13}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(4, 13))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19707 \\pmod{12}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(19707 % 12)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1513^2357 \\pmod{1583}$.", + "Output Answer": [ + "$1115$" + ], + "Output Program": [ + "print(pow(1513, 2357, 1583))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-840,140\\}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "import math\n\nvalues = -840, 140\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35610)$.", + "Output Answer": [ + "$9488$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35610))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n70379", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70379))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{649,246\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 649, 246\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{7207}{91}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{182} \\left(\\sqrt{51973973}-7207\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7207/91)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $452^2209 \\pmod{538}$.", + "Output Answer": [ + "$234$" + ], + "Output Program": [ + "print(pow(452, 2209, 538))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{247,-31,-970\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 247, -31, -970\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $212x \\equiv 1 \\pmod{1821}$.", + "Output Answer": [ + "$335$" + ], + "Output Program": [ + "print(pow(212, -1, 1821))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2065^654 \\pmod{2238}$.", + "Output Answer": [ + "$745$" + ], + "Output Program": [ + "print(pow(2065, 654, 2238))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $40694$.", + "Output Answer": [ + "$\\{3,5,13,19,21,29,33,35,41,51\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(40694):\n if len(roots) == 10: break\n if gcd(a, 40694) == 1 and is_primitive_root(a, 40694):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $644^2440 \\pmod{2716}$.", + "Output Answer": [ + "$2072$" + ], + "Output Program": [ + "print(pow(644, 2440, 2716))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{3853}{1807}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{27906605}-3853}{3614}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3853/1807)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2110$ to base $28$.", + "Output Answer": [ + "$\\text{2ja}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2110\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 81988 \\pmod{30}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(81988 % 30)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{16}$\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 8 \\pmod{3}$", + "Output Answer": [ + "$425$" + ], + "Output Program": [ + "constraints = (9, 16), (9, 13), (8, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 16), (9, 13), (8, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 16), (9, 13), (8, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $43x \\equiv 1 \\pmod{740}$.", + "Output Answer": [ + "$327$" + ], + "Output Program": [ + "print(pow(43, -1, 740))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $106^m \\equiv 1 \\pmod{667}$.", + "Output Answer": [ + "$308$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(106, 667))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $293^m \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(293, 322))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $266^1844 \\pmod{1479}$.", + "Output Answer": [ + "$310$" + ], + "Output Program": [ + "print(pow(266, 1844, 1479))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n20599", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(20599))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1181^1001 \\pmod{1421}$.", + "Output Answer": [ + "$423$" + ], + "Output Program": [ + "print(pow(1181, 1001, 1421))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $103$ is divisible by $15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(103 % 15 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $16433$.", + "Output Answer": [ + "$\\{3,5,6,10,11,12,17,20,22,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(16433):\n if len(roots) == 10: break\n if gcd(a, 16433) == 1 and is_primitive_root(a, 16433):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2141x \\equiv 1 \\pmod{2440}$.", + "Output Answer": [ + "$661$" + ], + "Output Program": [ + "print(pow(2141, -1, 2440))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $1712$ to base $19$.", + "Output Answer": [ + "$\\text{4e2}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1712\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{6}$\n$x \\equiv 18 \\pmod{7}$\n$x \\equiv 2 \\pmod{16}$\n$x \\equiv 16 \\pmod{19}$", + "Output Answer": [ + "$2258$" + ], + "Output Program": [ + "constraints = (2, 6), (18, 7), (2, 16), (16, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 6), (18, 7), (2, 16), (16, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $633$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(633 % -19 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.766$ to base $24$.", + "Output Answer": [ + "$\\text{0.i954}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.766\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $110$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(110 % -42 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73116 \\pmod{23}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(73116 % 23)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{163,172,186\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 163, 172, 186\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-840,283,-128\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -840, 283, -128\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 18 \\pmod{12}$", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 11), (18, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 11), (18, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 11), (18, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $351^m \\equiv 1 \\pmod{626}$.", + "Output Answer": [ + "$156$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(351, 626))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-2562$ is divisible by $12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2562 % 12 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5805)$.", + "Output Answer": [ + "$3024$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5805))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42210)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42210))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{143,102,-379\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 143, 102, -379\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31729 \\pmod{85}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(31729 % 85)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{17,45,191\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 17, 45, 191\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1314 \\pmod{30}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(1314 % 30)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25235)$.", + "Output Answer": [ + "$17136$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25235))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46269)$.", + "Output Answer": [ + "$29952$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46269))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{217,519,-390\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 217, 519, -390\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{22558}{17611}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{437363162}-11279}{17611}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22558/17611)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1005$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1005 % -22 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{14}$\n$x \\equiv 17 \\pmod{11}$", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 14), (17, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 14), (17, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 14), (17, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-3366$ is divisible by $9$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3366 % 9 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-977,-543,852\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -977, -543, 852\nprint(math.gcd(*values))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31213)$.", + "Output Answer": [ + "$24696$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31213))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{16}$\n$x \\equiv 5 \\pmod{5}$", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "constraints = (9, 16), (5, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 16), (5, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 16), (5, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99808 \\pmod{29}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(99808 % 29)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8601}{19567}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1605447157}-8601}{39134}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8601/19567)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $23^m \\equiv 1 \\pmod{121}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(23, 121))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-164,-465\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -164, -465\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34310)$.", + "Output Answer": [ + "$13248$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34310))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{939}{1276}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{295777}-939}{2552}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(939/1276)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-652,42\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -652, 42\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n59659", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59659))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $83^m \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(83, 322))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 4 \\pmod{16}$\n$x \\equiv 10 \\pmod{9}$\n$x \\equiv 0 \\pmod{2}$", + "Output Answer": [ + "$388$" + ], + "Output Program": [ + "constraints = (14, 17), (4, 16), (10, 9), (0, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (4, 16), (10, 9), (0, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9261}{1276}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{3691153}-9261}{2552}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9261/1276)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $38^m \\equiv 1 \\pmod{135}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(38, 135))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-6660$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6660 % 15 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $2246^1533 \\pmod{2661}$.", + "Output Answer": [ + "$944$" + ], + "Output Program": [ + "print(pow(2246, 1533, 2661))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44240 \\pmod{34}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(44240 % 34)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65538 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(65538 % 2)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{3}$\n$x \\equiv 12 \\pmod{2}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 3), (12, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 3), (12, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 3), (12, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{23960}{11279}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{270736241}-11980}{11279}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23960/11279)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $719x \\equiv 1 \\pmod{978}$.", + "Output Answer": [ + "$725$" + ], + "Output Program": [ + "print(pow(719, -1, 978))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n12791", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12791))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $198$ is divisible by $8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(198 % 8 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n39345", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(39345))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{17}$\n$x \\equiv 8 \\pmod{15}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$1958$" + ], + "Output Program": [ + "constraints = (20, 17), (8, 15), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 17), (8, 15), (1, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 17), (8, 15), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $55257$.", + "Output Answer": [ + "$3^1\\cdot 113^1\\cdot 163^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(55257))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1539}{1175}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7891021}-1539}{2350}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1539/1175)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2924)$.", + "Output Answer": [ + "$1344$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2924))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8909}{4246}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{151484345}-8909}{8492}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8909/4246)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77348 \\pmod{43}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(77348 % 43)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $747$.", + "Output Answer": [ + "$3^2\\cdot 83^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(747))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 0 \\pmod{3}$\n$x \\equiv 15 \\pmod{5}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (0, 3), (15, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (0, 3), (15, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 11), (0, 3), (15, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(672)$.", + "Output Answer": [ + "$192$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(672))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-301,238\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -301, 238\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-122,-101,67\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -122, -101, 67\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-12530$ is divisible by $-28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-12530 % -28 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $941^437 \\pmod{2376}$.", + "Output Answer": [ + "$1757$" + ], + "Output Program": [ + "print(pow(941, 437, 2376))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-10530$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10530 % -45 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $324x \\equiv 1 \\pmod{383}$.", + "Output Answer": [ + "$370$" + ], + "Output Program": [ + "print(pow(324, -1, 383))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $0.73333_{16}$ to base 10.", + "Output Answer": [ + "$0.45$" + ], + "Output Program": [ + "n = '0.73333'.strip('.')\nbase = 16\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $618^1572 \\pmod{686}$.", + "Output Answer": [ + "$246$" + ], + "Output Program": [ + "print(pow(618, 1572, 686))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12857 \\pmod{13}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(12857 % 13)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $31^m \\equiv 1 \\pmod{94}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(31, 94))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{377,263\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 377, 263\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{422,505\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 422, 505\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{486,919,643\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 486, 919, 643\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $15^m \\equiv 1 \\pmod{41}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(15, 41))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 4 \\pmod{12}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 3), (4, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 3), (4, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1266^1336 \\pmod{2930}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(pow(1266, 1336, 2930))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{15}$\n$x \\equiv 17 \\pmod{15}$\n$x \\equiv 7 \\pmod{10}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 15), (17, 15), (7, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 15), (17, 15), (7, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-447$ is divisible by $40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-447 % 40 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $57^m \\equiv 1 \\pmod{317}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(57, 317))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{546,514,915\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 546, 514, 915\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1188^2428 \\pmod{2095}$.", + "Output Answer": [ + "$1386$" + ], + "Output Program": [ + "print(pow(1188, 2428, 2095))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 11), (6, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{9917}{16150}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1141636889}-9917}{32300}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9917/16150)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1948^1817 \\pmod{2385}$.", + "Output Answer": [ + "$223$" + ], + "Output Program": [ + "print(pow(1948, 1817, 2385))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{207,623,418\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 207, 623, 418\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $66708$.", + "Output Answer": [ + "$2^2\\cdot 3^2\\cdot 17^1\\cdot 109^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(66708))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $299^m \\equiv 1 \\pmod{310}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(299, 310))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{8740}{4569}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{39972661}-4370}{4569}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8740/4569)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{11}$\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 1 \\pmod{20}$", + "Output Answer": [ + "$2161$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 11), (2, 17), (1, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 11), (2, 17), (1, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 11), (2, 17), (1, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $541x \\equiv 1 \\pmod{1188}$.", + "Output Answer": [ + "$325$" + ], + "Output Program": [ + "print(pow(541, -1, 1188))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{16}$\n$x \\equiv 20 \\pmod{18}$\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 20 \\pmod{19}$", + "Output Answer": [ + "$13016$" + ], + "Output Program": [ + "constraints = (8, 16), (20, 18), (11, 17), (20, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 16), (20, 18), (11, 17), (20, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90160 \\pmod{38}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(90160 % 38)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 2 \\pmod{10}$", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 11), (2, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 11), (2, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 11), (2, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $37502$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(37502 % -34 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $727x \\equiv 1 \\pmod{2289}$.", + "Output Answer": [ + "$1420$" + ], + "Output Program": [ + "print(pow(727, -1, 2289))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $5x \\equiv 1 \\pmod{28}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(5, -1, 28))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n27647", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(27647))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-4400$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4400 % -11 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-318,535\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -318, 535\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $133^m \\equiv 1 \\pmod{445}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(133, 445))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $1904^2318 \\pmod{2867}$.", + "Output Answer": [ + "$596$" + ], + "Output Program": [ + "print(pow(1904, 2318, 2867))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{18}$\n$x \\equiv 8 \\pmod{11}$", + "Output Answer": [ + "$74$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 18), (8, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 18), (8, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 18), (8, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10364)$.", + "Output Answer": [ + "$5180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10364))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 13288 \\pmod{93}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "print(13288 % 93)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $723$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(723 % 31 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{659}{1248}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6664297}-659}{2496}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(659/1248)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{11,327,24\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 11, 327, 24\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{75,-79,345\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 75, -79, 345\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4534 \\pmod{47}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(4534 % 47)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n31125", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31125))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $454$ is divisible by $35$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(454 % 35 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{269,824,759\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 269, 824, 759\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nSimplify $554^823 \\pmod{1684}$.", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "print(pow(554, 823, 1684))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{303,-38,21\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 303, -38, 21\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37029)$.", + "Output Answer": [ + "$24684$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37029))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $15797$.", + "Output Answer": [ + "$\\{2,3,5,7,8,12,13,18,19,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(15797):\n if len(roots) == 10: break\n if gcd(a, 15797) == 1 and is_primitive_root(a, 15797):\n roots.append(a)\nprint(roots)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $389x \\equiv 1 \\pmod{1630}$.", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "print(pow(389, -1, 1630))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{1249}{116}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{232} \\left(5 \\sqrt{64553}-1249\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1249/116)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $45^m \\equiv 1 \\pmod{536}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(45, 536))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{867}{11432}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{523514185}-867}{22864}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(867/11432)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $478x \\equiv 1 \\pmod{1383}$.", + "Output Answer": [ + "$217$" + ], + "Output Program": [ + "print(pow(478, -1, 1383))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $70187$.", + "Output Answer": [ + "$13^1\\cdot 5399^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(70187))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{2195}{2587}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{31588301}-2195}{5174}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2195/2587)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{8}$\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 15 \\pmod{5}$", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 8), (15, 9), (15, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 8), (15, 9), (15, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 8), (15, 9), (15, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $579x \\equiv 1 \\pmod{703}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(579, -1, 703))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nDetermine whether $-1983$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1983 % 27 == 0)\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $2943$ to base $2$.", + "Output Answer": [ + "$101101111111_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2943\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFactor $48470$.", + "Output Answer": [ + "$2^1\\cdot 5^1\\cdot 37^1\\cdot 131^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(48470))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{21955}{14804}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1358655689}-21955}{29608}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21955/14804)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIf $x = \\frac{34682}{27265}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1044090506}-17341}{27265}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34682/27265)')]]))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{588,832,293\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 588, 832, 293\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44802)$.", + "Output Answer": [ + "$14040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44802))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nConvert $161$ to base $36$.", + "Output Answer": [ + "$\\text{4h}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 161\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $389x \\equiv 1 \\pmod{562}$.", + "Output Answer": [ + "$549$" + ], + "Output Program": [ + "print(pow(389, -1, 562))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(1847)$.", + "Output Answer": [ + "$1846$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(1847))\n" + ], + "split": "dev" + }, + { + "Input": "Problem:\nIs the following number prime?\n47499", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(47499))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27390)$.", + "Output Answer": [ + "$6560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27390))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $750$ to base $23$.", + "Output Answer": [ + "$\\text{19e}_{23}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 23\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 750\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1837^275 \\pmod{2567}$.", + "Output Answer": [ + "$2534$" + ], + "Output Program": [ + "print(pow(1837, 275, 2567))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 11 \\pmod{19}$", + "Output Answer": [ + "$182$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 7), (17, 3), (11, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (17, 3), (11, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 7), (17, 3), (11, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-18165$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-18165 % -21 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $729^m \\equiv 1 \\pmod{850}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(729, 850))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $18^m \\equiv 1 \\pmod{803}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(18, 803))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10569)$.", + "Output Answer": [ + "$6480$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10569))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $60354$.", + "Output Answer": [ + "$2^1\\cdot 3^2\\cdot 7^1\\cdot 479^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(60354))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $201^m \\equiv 1 \\pmod{830}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(201, 830))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13330)$.", + "Output Answer": [ + "$5040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13330))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19404)$.", + "Output Answer": [ + "$5040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19404))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3225}{1468}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{19020721}-3225}{2936}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3225/1468)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-955,126,-769\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -955, 126, -769\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n44269", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(44269))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44059)$.", + "Output Answer": [ + "$44058$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44059))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{739,55,212\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 739, 55, 212\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-892$ is divisible by $-29$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-892 % -29 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-117,310\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -117, 310\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n49179", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(49179))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 7 \\pmod{20}$\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 2 \\pmod{3}$", + "Output Answer": [ + "$287$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 2), (7, 20), (12, 11), (2, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 2), (7, 20), (12, 11), (2, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-20108$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-20108 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n88095", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(88095))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $37649$.", + "Output Answer": [ + "$\\{3,6,7,11,12,14,15,17,19,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(37649):\n if len(roots) == 10: break\n if gcd(a, 37649) == 1 and is_primitive_root(a, 37649):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1301x \\equiv 1 \\pmod{1895}$.", + "Output Answer": [ + "$1241$" + ], + "Output Program": [ + "print(pow(1301, -1, 1895))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{621,555\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 621, 555\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19231 \\pmod{38}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(19231 % 38)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10459)$.", + "Output Answer": [ + "$10458$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10459))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5757}{4328}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{108069385}-5757}{8656}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5757/4328)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72301 \\pmod{34}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(72301 % 34)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{362,495\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 362, 495\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25705 \\pmod{67}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(25705 % 67)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-2990$ is divisible by $-13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2990 % -13 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n12819", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12819))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20539)$.", + "Output Answer": [ + "$18216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20539))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $744^1958 \\pmod{2065}$.", + "Output Answer": [ + "$466$" + ], + "Output Program": [ + "print(pow(744, 1958, 2065))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $436x \\equiv 1 \\pmod{937}$.", + "Output Answer": [ + "$591$" + ], + "Output Program": [ + "print(pow(436, -1, 937))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $909x \\equiv 1 \\pmod{1252}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(pow(909, -1, 1252))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 3 \\pmod{8}$", + "Output Answer": [ + "$5395$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (6, 17), (15, 10), (3, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 19), (6, 17), (15, 10), (3, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $323x \\equiv 1 \\pmod{900}$.", + "Output Answer": [ + "$287$" + ], + "Output Program": [ + "print(pow(323, -1, 900))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $386^m \\equiv 1 \\pmod{825}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(386, 825))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25219)$.", + "Output Answer": [ + "$25218$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25219))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $37^m \\equiv 1 \\pmod{156}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(37, 156))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $420x \\equiv 1 \\pmod{2431}$.", + "Output Answer": [ + "$1557$" + ], + "Output Program": [ + "print(pow(420, -1, 2431))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $20439$ is divisible by $27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(20439 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $67x \\equiv 1 \\pmod{1744}$.", + "Output Answer": [ + "$859$" + ], + "Output Program": [ + "print(pow(67, -1, 1744))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21778 \\pmod{36}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(21778 % 36)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $78616$.", + "Output Answer": [ + "$2^3\\cdot 31^1\\cdot 317^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(78616))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n65005", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65005))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $292x \\equiv 1 \\pmod{1079}$.", + "Output Answer": [ + "$388$" + ], + "Output Program": [ + "print(pow(292, -1, 1079))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37571)$.", + "Output Answer": [ + "$37570$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37571))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-5440$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5440 % -16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31989 \\pmod{43}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(31989 % 43)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{37191}{5099}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1487169685}-37191}{10198}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(37191/5099)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2903}{4431}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{86962453}-2903}{8862}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2903/4431)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 8 \\pmod{20}$\n$x \\equiv 0 \\pmod{9}$", + "Output Answer": [ + "$1728$" + ], + "Output Program": [ + "constraints = (1, 11), (8, 20), (0, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 11), (8, 20), (0, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 11), (8, 20), (0, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68555 \\pmod{95}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(68555 % 95)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{627,185,-577\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 627, 185, -577\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6707}{1044}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{49343593}-6707}{2088}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6707/1044)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $110^m \\equiv 1 \\pmod{123}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(110, 123))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1440$ is divisible by $-37$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1440 % -37 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $55^m \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(55, 322))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2089^1908 \\pmod{2305}$.", + "Output Answer": [ + "$531$" + ], + "Output Program": [ + "print(pow(2089, 1908, 2305))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{612}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 612))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $646x \\equiv 1 \\pmod{831}$.", + "Output Answer": [ + "$274$" + ], + "Output Program": [ + "print(pow(646, -1, 831))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 3 \\pmod{2}$\n$x \\equiv 11 \\pmod{16}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "constraints = (5, 2), (3, 2), (11, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 2), (3, 2), (11, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-136,428\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -136, 428\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-4280$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4280 % -10 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55145 \\pmod{52}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(55145 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-74,-741\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -74, -741\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-877,427\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -877, 427\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6859}{11235}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{551946781}-6859}{22470}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6859/11235)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97298 \\pmod{95}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(97298 % 95)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98885 \\pmod{81}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(98885 % 81)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{561,316,-11\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 561, 316, -11\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.3220030102_4$ to base 10.", + "Output Answer": [ + "$0.907$" + ], + "Output Program": [ + "n = '0.3220030102'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $127x \\equiv 1 \\pmod{748}$.", + "Output Answer": [ + "$695$" + ], + "Output Program": [ + "print(pow(127, -1, 748))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $484x \\equiv 1 \\pmod{1043}$.", + "Output Answer": [ + "$890$" + ], + "Output Program": [ + "print(pow(484, -1, 1043))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $661x \\equiv 1 \\pmod{1036}$.", + "Output Answer": [ + "$873$" + ], + "Output Program": [ + "print(pow(661, -1, 1036))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1531x \\equiv 1 \\pmod{1630}$.", + "Output Answer": [ + "$461$" + ], + "Output Program": [ + "print(pow(1531, -1, 1630))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9155}{8066}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{344055449}-9155}{16132}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9155/8066)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{11}$\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 13 \\pmod{3}$\n$x \\equiv 13 \\pmod{9}$", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 11), (16, 2), (13, 3), (13, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 11), (16, 2), (13, 3), (13, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{610,292,493\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 610, 292, 493\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $66^m \\equiv 1 \\pmod{401}$.", + "Output Answer": [ + "$400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(66, 401))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14522 \\pmod{4}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(14522 % 4)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $1600$.", + "Output Answer": [ + "$2^6\\cdot 5^2$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(1600))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-907,278\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -907, 278\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41971 \\pmod{28}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(41971 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{134,183,645\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 134, 183, 645\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39484 \\pmod{60}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(39484 % 60)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-773,-699\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -773, -699\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1063_{11}$ to base 10.", + "Output Answer": [ + "$1400$" + ], + "Output Program": [ + "n = '1063'.strip('.')\nbase = 11\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $193^m \\equiv 1 \\pmod{829}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(193, 829))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{34,579,-573\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 34, 579, -573\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n1359", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1359))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $409$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(409 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2284^2254 \\pmod{2732}$.", + "Output Answer": [ + "$1600$" + ], + "Output Program": [ + "print(pow(2284, 2254, 2732))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45422)$.", + "Output Answer": [ + "$20952$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45422))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $551x \\equiv 1 \\pmod{581}$.", + "Output Answer": [ + "$213$" + ], + "Output Program": [ + "print(pow(551, -1, 581))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35569 \\pmod{85}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(35569 % 85)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-80$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-80 % 16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{20}$\n$x \\equiv 13 \\pmod{9}$\n$x \\equiv 9 \\pmod{8}$", + "Output Answer": [ + "$193$" + ], + "Output Program": [ + "constraints = (13, 20), (13, 9), (9, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 20), (13, 9), (9, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34973)$.", + "Output Answer": [ + "$34080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34973))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39330)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39330))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23954)$.", + "Output Answer": [ + "$9744$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57976 \\pmod{68}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(57976 % 68)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15415)$.", + "Output Answer": [ + "$12328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15415))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23341 \\pmod{12}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(23341 % 12)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$1063$" + ], + "Output Program": [ + "constraints = (18, 19), (7, 8), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (7, 8), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 19), (7, 8), (6, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 8 \\pmod{15}$", + "Output Answer": [ + "$128$" + ], + "Output Program": [ + "constraints = (7, 11), (8, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (8, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 11), (8, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 16 \\pmod{17}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 2), (16, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 2), (16, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 2), (16, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38947)$.", + "Output Answer": [ + "$34944$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38947))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1059}{7180}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{207331081}-1059}{14360}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1059/7180)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1429x \\equiv 1 \\pmod{1956}$.", + "Output Answer": [ + "$193$" + ], + "Output Program": [ + "print(pow(1429, -1, 1956))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2258$ to base $16$.", + "Output Answer": [ + "$\\text{8d2}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2258\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{27,347,232\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 27, 347, 232\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-232,-418\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -232, -418\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9761 \\pmod{63}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(9761 % 63)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $429^m \\equiv 1 \\pmod{830}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(429, 830))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66731 \\pmod{42}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(66731 % 42)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 14 \\pmod{11}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 20), (14, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 20), (14, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 20), (14, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n56511", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(56511))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n104493", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(104493))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2867)$.", + "Output Answer": [ + "$2760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2867))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8235}{29842}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3629995081}-8235}{59684}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8235/29842)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{18}$\n$x \\equiv 0 \\pmod{11}$\n$x \\equiv 1 \\pmod{4}$", + "Output Answer": [ + "$297$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 18), (0, 11), (1, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 18), (0, 11), (1, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.0140303031_5$ to base 10.", + "Output Answer": [ + "$0.073$" + ], + "Output Program": [ + "n = '0.0140303031'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2264^1416 \\pmod{2459}$.", + "Output Answer": [ + "$1299$" + ], + "Output Program": [ + "print(pow(2264, 1416, 2459))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $40169$.", + "Output Answer": [ + "$\\{3,6,7,11,12,14,15,19,22,23\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(40169):\n if len(roots) == 10: break\n if gcd(a, 40169) == 1 and is_primitive_root(a, 40169):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8799)$.", + "Output Answer": [ + "$5016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8799))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1163x \\equiv 1 \\pmod{1979}$.", + "Output Answer": [ + "$1249$" + ], + "Output Program": [ + "print(pow(1163, -1, 1979))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 2 \\pmod{11}$", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "constraints = (16, 2), (16, 3), (2, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 2), (16, 3), (2, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 2), (16, 3), (2, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-701,-274\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -701, -274\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{2}$\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 20 \\pmod{15}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "constraints = (2, 2), (10, 2), (20, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 2), (10, 2), (20, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{3}$\n$x \\equiv 20 \\pmod{2}$\n$x \\equiv 20 \\pmod{16}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "constraints = (19, 3), (20, 2), (20, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 3), (20, 2), (20, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $21220_6$ to base 10.", + "Output Answer": [ + "$2892$" + ], + "Output Program": [ + "n = '21220'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-7632$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7632 % 18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $292^m \\equiv 1 \\pmod{297}$.", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(292, 297))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $6006$ is divisible by $11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6006 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{879}{1151}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6071845}-879}{2302}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(879/1151)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1911^235 \\pmod{2846}$.", + "Output Answer": [ + "$877$" + ], + "Output Program": [ + "print(pow(1911, 235, 2846))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{19}$\n$x \\equiv 8 \\pmod{12}$\n$x \\equiv 8 \\pmod{3}$", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 19), (8, 12), (8, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 19), (8, 12), (8, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{13}$\n$x \\equiv 20 \\pmod{4}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$668$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 13), (20, 4), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 13), (20, 4), (5, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 13), (20, 4), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.73$ to base $36$.", + "Output Answer": [ + "$\\text{0.qa2w}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.73\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 12 \\pmod{3}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 5), (12, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 5), (12, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 5), (12, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6057}{5872}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{174608785}-6057}{11744}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6057/5872)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $233x \\equiv 1 \\pmod{541}$.", + "Output Answer": [ + "$339$" + ], + "Output Program": [ + "print(pow(233, -1, 541))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19040 \\pmod{16}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(19040 % 16)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1923}{6031}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{149189773}-1923}{12062}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1923/6031)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{17}$\n$x \\equiv 20 \\pmod{20}$", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "constraints = (9, 17), (20, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 17), (20, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 17), (20, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $50x \\equiv 1 \\pmod{187}$.", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "print(pow(50, -1, 187))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{772,877\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 772, 877\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{31176}{8015}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{307225969}-15588}{8015}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31176/8015)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-478$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-478 % -23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-942$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-942 % -30 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n12851", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12851))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $731x \\equiv 1 \\pmod{1005}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(pow(731, -1, 1005))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $120$ is divisible by $-4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(120 % -4 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.176811_9$ to base 10.", + "Output Answer": [ + "$0.207$" + ], + "Output Program": [ + "n = '0.176811'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 7 \\pmod{4}$\n$x \\equiv 15 \\pmod{12}$", + "Output Answer": [ + "$123$" + ], + "Output Program": [ + "constraints = (13, 11), (7, 4), (15, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (7, 4), (15, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = 66$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\sqrt{1090}-33$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('66')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29018)$.", + "Output Answer": [ + "$13180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29018))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10850}{4413}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{48905194}-5425}{4413}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10850/4413)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5461}{11865}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{592935421}-5461}{23730}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5461/11865)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1054$ is divisible by $43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1054 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19721}{34002}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5013461857}-19721}{68004}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19721/34002)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{16}$\n$x \\equiv 4 \\pmod{13}$", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 16), (4, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 16), (4, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 16), (4, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-535,245,411\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -535, 245, 411\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38892)$.", + "Output Answer": [ + "$11088$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38892))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{620,-881\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 620, -881\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $370$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(370 % 31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $794x \\equiv 1 \\pmod{1401}$.", + "Output Answer": [ + "$944$" + ], + "Output Program": [ + "print(pow(794, -1, 1401))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1817x \\equiv 1 \\pmod{2022}$.", + "Output Answer": [ + "$1805$" + ], + "Output Program": [ + "print(pow(1817, -1, 2022))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1755$ is divisible by $40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1755 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26730 \\pmod{63}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(26730 % 63)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{669,212\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 669, 212\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n74923", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(74923))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $517x \\equiv 1 \\pmod{1292}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(pow(517, -1, 1292))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.3320616_7$ to base 10.", + "Output Answer": [ + "$0.496$" + ], + "Output Program": [ + "n = '0.3320616'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{17}$\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 2 \\pmod{6}$", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 17), (14, 7), (2, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 17), (14, 7), (2, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 17), (14, 7), (2, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50582 \\pmod{28}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(50582 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1984^1906 \\pmod{2185}$.", + "Output Answer": [ + "$676$" + ], + "Output Program": [ + "print(pow(1984, 1906, 2185))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $403^m \\equiv 1 \\pmod{524}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(403, 524))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65234 \\pmod{77}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(65234 % 77)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24399 \\pmod{72}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(24399 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(954)$.", + "Output Answer": [ + "$312$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $175^1857 \\pmod{2656}$.", + "Output Answer": [ + "$1807$" + ], + "Output Program": [ + "print(pow(175, 1857, 2656))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{30220}{12881}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{394232261}-15110}{12881}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30220/12881)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1349x \\equiv 1 \\pmod{2209}$.", + "Output Answer": [ + "$2078$" + ], + "Output Program": [ + "print(pow(1349, -1, 2209))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{160,-242\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 160, -242\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $801x \\equiv 1 \\pmod{1994}$.", + "Output Answer": [ + "$1877$" + ], + "Output Program": [ + "print(pow(801, -1, 1994))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $408^m \\equiv 1 \\pmod{823}$.", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(408, 823))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2257^1081 \\pmod{2918}$.", + "Output Answer": [ + "$1361$" + ], + "Output Program": [ + "print(pow(2257, 1081, 2918))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $63322$.", + "Output Answer": [ + "$2^1\\cdot 7^1\\cdot 4523^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(63322))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $188x \\equiv 1 \\pmod{2121}$.", + "Output Answer": [ + "$440$" + ], + "Output Program": [ + "print(pow(188, -1, 2121))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $613x \\equiv 1 \\pmod{770}$.", + "Output Answer": [ + "$667$" + ], + "Output Program": [ + "print(pow(613, -1, 770))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65415 \\pmod{50}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(65415 % 50)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $789^1695 \\pmod{1772}$.", + "Output Answer": [ + "$1237$" + ], + "Output Program": [ + "print(pow(789, 1695, 1772))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $3708$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3708 % 12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 2 \\pmod{6}$\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 20 \\pmod{15}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "constraints = (16, 8), (2, 6), (0, 16), (20, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 8), (2, 6), (0, 16), (20, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1203_{11}$ to base 10.", + "Output Answer": [ + "$1576$" + ], + "Output Program": [ + "n = '1203'.strip('.')\nbase = 11\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $265^m \\equiv 1 \\pmod{611}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(265, 611))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1652^515 \\pmod{2790}$.", + "Output Answer": [ + "$2288$" + ], + "Output Program": [ + "print(pow(1652, 515, 2790))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{17}$\n$x \\equiv 12 \\pmod{11}$", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "constraints = (15, 17), (12, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 17), (12, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 17), (12, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{9}$\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (15, 9), (12, 3), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 9), (12, 3), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{12}$\n$x \\equiv 9 \\pmod{11}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 12), (9, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 12), (9, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 12), (9, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $410x \\equiv 1 \\pmod{1567}$.", + "Output Answer": [ + "$1288$" + ], + "Output Program": [ + "print(pow(410, -1, 1567))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $73x \\equiv 1 \\pmod{241}$.", + "Output Answer": [ + "$208$" + ], + "Output Program": [ + "print(pow(73, -1, 241))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $222^90 \\pmod{2335}$.", + "Output Answer": [ + "$2104$" + ], + "Output Program": [ + "print(pow(222, 90, 2335))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-133$ is divisible by $12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-133 % 12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-6834$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6834 % -34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43512 \\pmod{6}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(43512 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36953)$.", + "Output Answer": [ + "$31668$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36953))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-281$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-281 % -11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $38497$.", + "Output Answer": [ + "$137^1\\cdot 281^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(38497))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36706)$.", + "Output Answer": [ + "$18352$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36706))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{20}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "constraints = (14, 20), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 20), (3, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 20), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $147$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(147 % -23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n47055", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(47055))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59412 \\pmod{78}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(59412 % 78)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-247,-572,-966\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -247, -572, -966\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56786 \\pmod{56}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(56786 % 56)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29126$.", + "Output Answer": [ + "$\\{3,19,21,23,33,35,37,39,45,55\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29126):\n if len(roots) == 10: break\n if gcd(a, 29126) == 1 and is_primitive_root(a, 29126):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28913)$.", + "Output Answer": [ + "$27888$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28913))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $39706$.", + "Output Answer": [ + "$\\{3,5,13,17,21,27,29,33,35,43\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(39706):\n if len(roots) == 10: break\n if gcd(a, 39706) == 1 and is_primitive_root(a, 39706):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38884)$.", + "Output Answer": [ + "$19440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38884))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21383 \\pmod{6}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(21383 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $51973$.", + "Output Answer": [ + "$\\{2,5,7,18,19,21,22,24,26,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(51973):\n if len(roots) == 10: break\n if gcd(a, 51973) == 1 and is_primitive_root(a, 51973):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 7 \\pmod{18}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 3), (4, 3), (7, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 3), (4, 3), (7, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{418,-772,399\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 418, -772, 399\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $47317$.", + "Output Answer": [ + "$\\{6,11,15,17,18,24,26,29,31,42\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(47317):\n if len(roots) == 10: break\n if gcd(a, 47317) == 1 and is_primitive_root(a, 47317):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $879$ to base $18$.", + "Output Answer": [ + "$\\text{2cf}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 879\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $830$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(830 % 18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{113,-946\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 113, -946\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n55829", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55829))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $313^m \\equiv 1 \\pmod{725}$.", + "Output Answer": [ + "$140$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(313, 725))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1594}{28749}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{827140210}-797}{28749}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1594/28749)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{22732}{22129}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{618878597}-11366}{22129}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22732/22129)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34026)$.", + "Output Answer": [ + "$11024$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34026))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1840^2498 \\pmod{2320}$.", + "Output Answer": [ + "$1760$" + ], + "Output Program": [ + "print(pow(1840, 2498, 2320))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 1 \\pmod{6}$\n$x \\equiv 15 \\pmod{8}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (1, 6), (15, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 17), (1, 6), (15, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{7}$\n$x \\equiv 4 \\pmod{12}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "constraints = (5, 7), (4, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (5, 7), (4, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 7), (4, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-484$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-484 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-41013$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-41013 % -31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{465}{322}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{644} \\left(\\sqrt{630961}-465\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(465/322)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $593x \\equiv 1 \\pmod{800}$.", + "Output Answer": [ + "$657$" + ], + "Output Program": [ + "print(pow(593, -1, 800))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $259^m \\equiv 1 \\pmod{834}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(259, 834))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48944 \\pmod{39}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(48944 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.931$ to base $18$.", + "Output Answer": [ + "$\\text{0.gdbac}_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.931\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{14}$\n$x \\equiv 18 \\pmod{15}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (4, 14), (18, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 14), (18, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 14), (18, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1769x \\equiv 1 \\pmod{2245}$.", + "Output Answer": [ + "$1929$" + ], + "Output Program": [ + "print(pow(1769, -1, 2245))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.23508_{14}$ to base 10.", + "Output Answer": [ + "$0.16$" + ], + "Output Program": [ + "n = '0.23508'.strip('.')\nbase = 14\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{504,391,367\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 504, 391, 367\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $547x \\equiv 1 \\pmod{865}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(pow(547, -1, 865))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $725^m \\equiv 1 \\pmod{833}$.", + "Output Answer": [ + "$336$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(725, 833))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{23,-861,242\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 23, -861, 242\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $32x \\equiv 1 \\pmod{105}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(pow(32, -1, 105))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20933)$.", + "Output Answer": [ + "$18920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20933))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3840$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3840 % 25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40998 \\pmod{59}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(40998 % 59)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $440x \\equiv 1 \\pmod{2191}$.", + "Output Answer": [ + "$244$" + ], + "Output Program": [ + "print(pow(440, -1, 2191))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-334$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-334 % 22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-925,25,-129\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -925, 25, -129\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{11512}{10373}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{140730665}-5756}{10373}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11512/10373)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $45131$.", + "Output Answer": [ + "$\\{2,6,7,8,11,13,18,19,24,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(45131):\n if len(roots) == 10: break\n if gcd(a, 45131) == 1 and is_primitive_root(a, 45131):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{986,-882\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 986, -882\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-539,11,292\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -539, 11, 292\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3067}{5088}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{112957465}-3067}{10176}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3067/5088)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{861,-309,31\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 861, -309, 31\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $19^2356 \\pmod{2593}$.", + "Output Answer": [ + "$2585$" + ], + "Output Program": [ + "print(pow(19, 2356, 2593))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{7}$\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 9 \\pmod{11}$", + "Output Answer": [ + "$152$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 7), (17, 3), (9, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (5, 7), (17, 3), (9, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 7), (17, 3), (9, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67420 \\pmod{82}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(67420 % 82)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{16361}{22022}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2207556257}-16361}{44044}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16361/22022)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{5}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (11, 5), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (11, 5), (6, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 5), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $89726$.", + "Output Answer": [ + "$2^1\\cdot 7^1\\cdot 13^1\\cdot 17^1\\cdot 29^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(89726))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $508x \\equiv 1 \\pmod{1133}$.", + "Output Answer": [ + "$765$" + ], + "Output Program": [ + "print(pow(508, -1, 1133))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{11}$\n$x \\equiv 3 \\pmod{7}$", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 11), (3, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (18, 11), (3, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 11), (3, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n675", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(675))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27996)$.", + "Output Answer": [ + "$9328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27996))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-247,-982\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -247, -982\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 9 \\pmod{17}$", + "Output Answer": [ + "$264$" + ], + "Output Program": [ + "constraints = (12, 18), (9, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 18), (9, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (9, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{19}$\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 16 \\pmod{8}$", + "Output Answer": [ + "$232$" + ], + "Output Program": [ + "constraints = (4, 19), (1, 3), (16, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 19), (1, 3), (16, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 19), (1, 3), (16, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{83,457\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 83, 457\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66899 \\pmod{27}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(66899 % 27)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15226 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(15226 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{18}$\n$x \\equiv 0 \\pmod{7}$", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "constraints = (4, 18), (0, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 18), (0, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 18), (0, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3348)$.", + "Output Answer": [ + "$1080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3348))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 91313 \\pmod{46}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(91313 % 46)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $675x \\equiv 1 \\pmod{2176}$.", + "Output Answer": [ + "$1931$" + ], + "Output Program": [ + "print(pow(675, -1, 2176))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49985)$.", + "Output Answer": [ + "$36864$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49985))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $105^776 \\pmod{2147}$.", + "Output Answer": [ + "$1259$" + ], + "Output Program": [ + "print(pow(105, 776, 2147))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $423$ is divisible by $-9$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(423 % -9 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-11$ is divisible by $-4$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-11 % -4 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-23520$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-23520 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n56683", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(56683))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2492}{1569}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4014277}-1246}{1569}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2492/1569)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30178)$.", + "Output Answer": [ + "$14820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30178))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49914)$.", + "Output Answer": [ + "$16008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49914))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{312,-18,787\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 312, -18, 787\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $754$ is divisible by $13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(754 % 13 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{17}$\n$x \\equiv 14 \\pmod{20}$", + "Output Answer": [ + "$314$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 17), (14, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 17), (14, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 17), (14, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{339,338,-466\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 339, 338, -466\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $39570$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(39570 % -30 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{674,528\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 674, 528\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33492)$.", + "Output Answer": [ + "$11160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33492))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2356^258 \\pmod{2924}$.", + "Output Answer": [ + "$2412$" + ], + "Output Program": [ + "print(pow(2356, 258, 2924))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.862$ to base $13$.", + "Output Answer": [ + "$\\text{0.b28a8}_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.862\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n47269", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(47269))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-72240$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-72240 % -40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6007 \\pmod{88}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(6007 % 88)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $4505$.", + "Output Answer": [ + "$5^1\\cdot 17^1\\cdot 53^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(4505))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6779}{506}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46978985}-6779}{1012}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6779/506)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1915}{8656}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{303372569}-1915}{17312}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1915/8656)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{401,257,196\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 401, 257, 196\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{10}$\n$x \\equiv 14 \\pmod{11}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 10), (14, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 10), (14, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 10), (14, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{31118}{27867}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1018652170}-15559}{27867}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31118/27867)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-630,86\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -630, 86\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5079}{1867}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{39738997}-5079}{3734}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5079/1867)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 66214 \\pmod{53}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(66214 % 53)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96709 \\pmod{18}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(96709 % 18)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $106^m \\equiv 1 \\pmod{195}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(106, 195))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60549 \\pmod{24}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(60549 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.44235013_6$ to base 10.", + "Output Answer": [ + "$0.79$" + ], + "Output Program": [ + "n = '0.44235013'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{318,-730\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 318, -730\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-72,37,98\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -72, 37, 98\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $44^m \\equiv 1 \\pmod{49}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(44, 49))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{227,358,534\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 227, 358, 534\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $22966$.", + "Output Answer": [ + "$\\{5,15,19,23,35,37,41,45,53,55\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(22966):\n if len(roots) == 10: break\n if gcd(a, 22966) == 1 and is_primitive_root(a, 22966):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89541 \\pmod{75}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "print(89541 % 75)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2040^911 \\pmod{2376}$.", + "Output Answer": [ + "$1512$" + ], + "Output Program": [ + "print(pow(2040, 911, 2376))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43099 \\pmod{34}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(43099 % 34)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87321 \\pmod{43}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(87321 % 43)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $51343$.", + "Output Answer": [ + "$\\{5,6,10,12,26,33,34,35,37,38\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(51343):\n if len(roots) == 10: break\n if gcd(a, 51343) == 1 and is_primitive_root(a, 51343):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n48283", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(48283))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4522)$.", + "Output Answer": [ + "$1728$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4522))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-899,790\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -899, 790\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{11822}{4551}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{55651522}-5911}{4551}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11822/4551)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-279,-989\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -279, -989\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-869,170\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -869, 170\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $229$ to base $32$.", + "Output Answer": [ + "$75_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 229\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2202^1682 \\pmod{2789}$.", + "Output Answer": [ + "$1170$" + ], + "Output Program": [ + "print(pow(2202, 1682, 2789))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{964,268\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 964, 268\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{858,-963,767\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 858, -963, 767\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87953 \\pmod{64}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(87953 % 64)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{45825}{44552}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10039453441}-45825}{89104}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(45825/44552)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $31^m \\equiv 1 \\pmod{408}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(31, 408))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{732,-92\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 732, -92\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1770^52 \\pmod{2616}$.", + "Output Answer": [ + "$768$" + ], + "Output Program": [ + "print(pow(1770, 52, 2616))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12493}{11147}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{653097485}-12493}{22294}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12493/11147)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $320x \\equiv 1 \\pmod{429}$.", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "print(pow(320, -1, 429))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $561x \\equiv 1 \\pmod{1960}$.", + "Output Answer": [ + "$1401$" + ], + "Output Program": [ + "print(pow(561, -1, 1960))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $206x \\equiv 1 \\pmod{231}$.", + "Output Answer": [ + "$194$" + ], + "Output Program": [ + "print(pow(206, -1, 231))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $873^m \\equiv 1 \\pmod{935}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(873, 935))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32997)$.", + "Output Answer": [ + "$20672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32997))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{905}{6402}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{164761441}-905}{12804}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(905/6402)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{14}$\n$x \\equiv 2 \\pmod{20}$\n$x \\equiv 6 \\pmod{3}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$6822$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 14), (2, 20), (6, 3), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 14), (2, 20), (6, 3), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-587,111\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -587, 111\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{139,324,615\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 139, 324, 615\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14531 \\pmod{54}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(14531 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-407,423\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -407, 423\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7616 \\pmod{41}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(7616 % 41)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21780)$.", + "Output Answer": [ + "$5280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21780))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $984x \\equiv 1 \\pmod{1541}$.", + "Output Answer": [ + "$1458$" + ], + "Output Program": [ + "print(pow(984, -1, 1541))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $816^895 \\pmod{2459}$.", + "Output Answer": [ + "$1154$" + ], + "Output Program": [ + "print(pow(816, 895, 2459))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $784$ is divisible by $-28$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(784 % -28 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $376x \\equiv 1 \\pmod{853}$.", + "Output Answer": [ + "$152$" + ], + "Output Program": [ + "print(pow(376, -1, 853))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $2081$.", + "Output Answer": [ + "$\\{3,6,17,19,21,23,27,30,34,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(2081):\n if len(roots) == 10: break\n if gcd(a, 2081) == 1 and is_primitive_root(a, 2081):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $269^m \\equiv 1 \\pmod{675}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(269, 675))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1647}{14942}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{895766065}-1647}{29884}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1647/14942)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-990,929\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -990, 929\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\n\nDetermine the $n=3$ $21$-gonal number.\n", + "Output Answer": [ + "$231$" + ], + "Output Program": [ + "n = 3\nk = 21\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10131)$.", + "Output Answer": [ + "$6120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10131))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{178}{85}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{85} \\left(\\sqrt{15146}-89\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(178/85)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{209,-210,187\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 209, -210, 187\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5194 \\pmod{52}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(5194 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17237}{28112}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3458252345}-17237}{56224}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17237/28112)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5115}{4637}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{112170301}-5115}{9274}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5115/4637)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(309)$.", + "Output Answer": [ + "$204$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(309))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $822^1589 \\pmod{1003}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "print(pow(822, 1589, 1003))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62598 \\pmod{29}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(62598 % 29)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $188x \\equiv 1 \\pmod{1037}$.", + "Output Answer": [ + "$171$" + ], + "Output Program": [ + "print(pow(188, -1, 1037))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{276,692\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 276, 692\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{27062}{25451}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{830841362}-13531}{25451}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27062/25451)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{973,858\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 973, 858\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-9506$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9506 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 6 \\pmod{2}$\n$x \\equiv 3 \\pmod{9}$", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (6, 2), (3, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 6), (6, 2), (3, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n55209", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55209))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1009$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1009 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $202^m \\equiv 1 \\pmod{265}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(202, 265))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n65423", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65423))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1591$ to base $17$.", + "Output Answer": [ + "$\\text{58a}_{17}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 17\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1591\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $57x \\equiv 1 \\pmod{1396}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(pow(57, -1, 1396))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{2}$\n$x \\equiv 10 \\pmod{19}$\n$x \\equiv 10 \\pmod{10}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 2), (10, 19), (10, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 2), (10, 19), (10, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2115}{11339}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{518764909}-2115}{22678}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2115/11339)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $1^m \\equiv 1 \\pmod{95}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(1, 95))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-660,-334\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -660, -334\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60953 \\pmod{86}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(60953 % 86)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(708)$.", + "Output Answer": [ + "$232$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(708))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-808,681\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -808, 681\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{26381}{12600}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1330997161}-26381}{25200}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26381/12600)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $350x \\equiv 1 \\pmod{1051}$.", + "Output Answer": [ + "$1048$" + ], + "Output Program": [ + "print(pow(350, -1, 1051))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 4 \\pmod{15}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 8), (4, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 8), (4, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 8), (4, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{9}$\n$x \\equiv 1 \\pmod{10}$\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 13 \\pmod{8}$", + "Output Answer": [ + "$3621$" + ], + "Output Program": [ + "constraints = (12, 9), (1, 10), (2, 11), (13, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 9), (1, 10), (2, 11), (13, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $719^m \\equiv 1 \\pmod{829}$.", + "Output Answer": [ + "$276$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(719, 829))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40213)$.", + "Output Answer": [ + "$40212$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40213))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53173$.", + "Output Answer": [ + "$\\{18,20,23,24,33,35,38,42,45,50\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53173):\n if len(roots) == 10: break\n if gcd(a, 53173) == 1 and is_primitive_root(a, 53173):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40882 \\pmod{6}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(40882 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{31195}{38831}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7004514269}-31195}{77662}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(31195/38831)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-4,-1,2\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -4, -1, 2\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{242,18,19\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 242, 18, 19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83229 \\pmod{90}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "print(83229 % 90)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{756,-937,-306\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 756, -937, -306\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $683_{15}$ to base 10.", + "Output Answer": [ + "$1473$" + ], + "Output Program": [ + "n = '683'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{18061}{12328}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{934118057}-18061}{24656}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18061/12328)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43385)$.", + "Output Answer": [ + "$34704$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43385))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{994,-929,-528\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 994, -929, -528\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $999$ to base $27$.", + "Output Answer": [ + "$\\text{1a0}_{27}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 27\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 999\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{20}$\n$x \\equiv 20 \\pmod{13}$\n$x \\equiv 11 \\pmod{11}$", + "Output Answer": [ + "$2035$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 20), (20, 13), (11, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 20), (20, 13), (11, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 20), (20, 13), (11, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12230}{9083}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{119894114}-6115}{9083}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12230/9083)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 12 \\pmod{8}$\n$x \\equiv 18 \\pmod{9}$", + "Output Answer": [ + "$612$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 11), (12, 8), (18, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (12, 8), (18, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 11), (12, 8), (18, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $39$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(39 % -17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $687^m \\equiv 1 \\pmod{910}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(687, 910))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2304^1795 \\pmod{2702}$.", + "Output Answer": [ + "$1744$" + ], + "Output Program": [ + "print(pow(2304, 1795, 2702))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $175^m \\equiv 1 \\pmod{356}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(175, 356))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2146^937 \\pmod{2580}$.", + "Output Answer": [ + "$376$" + ], + "Output Program": [ + "print(pow(2146, 937, 2580))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{919,577\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 919, 577\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16794)$.", + "Output Answer": [ + "$5580$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16794))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $45763$.", + "Output Answer": [ + "$\\{5,11,20,26,30,34,39,43,44,45\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(45763):\n if len(roots) == 10: break\n if gcd(a, 45763) == 1 and is_primitive_root(a, 45763):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-5016$ is divisible by $18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-5016 % 18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-2280$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2280 % -10 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1145^36 \\pmod{1887}$.", + "Output Answer": [ + "$667$" + ], + "Output Program": [ + "print(pow(1145, 36, 1887))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{659,535\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 659, 535\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-945,347\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -945, 347\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{75,-119,918\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 75, -119, 918\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $342$ is divisible by $-4$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(342 % -4 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{13}$\n$x \\equiv 15 \\pmod{16}$\n$x \\equiv 15 \\pmod{15}$", + "Output Answer": [ + "$1215$" + ], + "Output Program": [ + "constraints = (6, 13), (15, 16), (15, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 13), (15, 16), (15, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 13), (15, 16), (15, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{140}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 140))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n83407", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83407))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10916}{5509}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{60138845}-5458}{5509}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10916/5509)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 15 \\pmod{14}$", + "Output Answer": [ + "$673$" + ], + "Output Program": [ + "constraints = (8, 19), (1, 3), (15, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 19), (1, 3), (15, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (1, 3), (15, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54234 \\pmod{39}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(54234 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $179x \\equiv 1 \\pmod{693}$.", + "Output Answer": [ + "$422$" + ], + "Output Program": [ + "print(pow(179, -1, 693))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{2}$\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 0 \\pmod{17}$\n$x \\equiv 4 \\pmod{19}$", + "Output Answer": [ + "$612$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 2), (17, 17), (0, 17), (4, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 2), (17, 17), (0, 17), (4, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $75062$.", + "Output Answer": [ + "$2^1\\cdot 13^1\\cdot 2887^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(75062))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40149)$.", + "Output Answer": [ + "$26748$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40149))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80658 \\pmod{96}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(80658 % 96)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-14430$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-14430 % 37 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $179^m \\equiv 1 \\pmod{332}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(179, 332))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1929$ to base $14$.", + "Output Answer": [ + "$\\text{9bb}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1929\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1147$ is divisible by $-28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1147 % -28 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $955x \\equiv 1 \\pmod{1083}$.", + "Output Answer": [ + "$973$" + ], + "Output Program": [ + "print(pow(955, -1, 1083))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-779,-114\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -779, -114\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $20$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(20 % -8 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1181$ to base $29$.", + "Output Answer": [ + "$\\text{1bl}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1181\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1883x \\equiv 1 \\pmod{2488}$.", + "Output Answer": [ + "$1427$" + ], + "Output Program": [ + "print(pow(1883, -1, 2488))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $157x \\equiv 1 \\pmod{1002}$.", + "Output Answer": [ + "$217$" + ], + "Output Program": [ + "print(pow(157, -1, 1002))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67887 \\pmod{35}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(67887 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1827^2031 \\pmod{2151}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(1827, 2031, 2151))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60190 \\pmod{19}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(60190 % 19)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1196$ to base $29$.", + "Output Answer": [ + "$\\text{1c7}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1196\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2411^2258 \\pmod{2546}$.", + "Output Answer": [ + "$1073$" + ], + "Output Program": [ + "print(pow(2411, 2258, 2546))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $448x \\equiv 1 \\pmod{1235}$.", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "print(pow(448, -1, 1235))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1815^366 \\pmod{2079}$.", + "Output Answer": [ + "$1485$" + ], + "Output Program": [ + "print(pow(1815, 366, 2079))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22549)$.", + "Output Answer": [ + "$22548$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22549))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $5372$.", + "Output Answer": [ + "$2^2\\cdot 17^1\\cdot 79^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(5372))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n66447", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(66447))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1400^53 \\pmod{2725}$.", + "Output Answer": [ + "$2475$" + ], + "Output Program": [ + "print(pow(1400, 53, 2725))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5295}{25004}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2528837089}-5295}{50008}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5295/25004)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{7}$\n$x \\equiv 15 \\pmod{4}$\n$x \\equiv 9 \\pmod{6}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "constraints = (10, 7), (15, 4), (9, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 7), (15, 4), (9, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25596)$.", + "Output Answer": [ + "$8424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25596))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{19}$\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 14 \\pmod{12}$", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 19), (15, 11), (14, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 19), (15, 11), (14, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 19), (15, 11), (14, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{751}{1485}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9384901}-751}{2970}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(751/1485)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71461 \\pmod{57}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(71461 % 57)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8234}{5041}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{42361370}-4117}{5041}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8234/5041)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $21$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(21 % -19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-875,-504\\}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "import math\n\nvalues = -875, -504\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $84$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(84 % 9 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $26372$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(26372 % -38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29698)$.", + "Output Answer": [ + "$14340$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29698))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2439^884 \\pmod{2937}$.", + "Output Answer": [ + "$2589$" + ], + "Output Program": [ + "print(pow(2439, 884, 2937))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53342 \\pmod{48}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(53342 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{524,13,-48\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 524, 13, -48\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $359x \\equiv 1 \\pmod{561}$.", + "Output Answer": [ + "$536$" + ], + "Output Program": [ + "print(pow(359, -1, 561))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $218^m \\equiv 1 \\pmod{659}$.", + "Output Answer": [ + "$658$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(218, 659))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{9}$\n$x \\equiv 5 \\pmod{3}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 9), (5, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 9), (5, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1772^476 \\pmod{2687}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(pow(1772, 476, 2687))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6584)$.", + "Output Answer": [ + "$3288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6584))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-3,2,1,-2\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = -3, 2, 1, -2\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{10}$\n$x \\equiv 4 \\pmod{15}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 10), (4, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 10), (4, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1012$ is divisible by $39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1012 % 39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $820^853 \\pmod{885}$.", + "Output Answer": [ + "$700$" + ], + "Output Program": [ + "print(pow(820, 853, 885))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49691 \\pmod{40}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(49691 % 40)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n21317", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21317))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n85671", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(85671))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{854,-364\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 854, -364\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n10489", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10489))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{14533}{25950}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2904818089}-14533}{51900}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14533/25950)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2080^1073 \\pmod{2420}$.", + "Output Answer": [ + "$980$" + ], + "Output Program": [ + "print(pow(2080, 1073, 2420))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-24,131,644\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -24, 131, 644\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{637,641\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 637, 641\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54666 \\pmod{75}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "print(54666 % 75)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{160,-824\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 160, -824\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1466$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1466 % -16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{468,979,-797\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 468, 979, -797\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $265x \\equiv 1 \\pmod{1236}$.", + "Output Answer": [ + "$625$" + ], + "Output Program": [ + "print(pow(265, -1, 1236))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $6335_7$ to base 10.", + "Output Answer": [ + "$2231$" + ], + "Output Program": [ + "n = '6335'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{747,291,-454\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 747, 291, -454\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40724)$.", + "Output Answer": [ + "$20360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40724))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $119^m \\equiv 1 \\pmod{417}$.", + "Output Answer": [ + "$138$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(119, 417))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{34516}{34737}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1504497733}-17258}{34737}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34516/34737)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1856}{1813}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4148153}-928}{1813}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1856/1813)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1566$ is divisible by $35$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1566 % 35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75796 \\pmod{25}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(75796 % 25)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2149^2258 \\pmod{2309}$.", + "Output Answer": [ + "$368$" + ], + "Output Program": [ + "print(pow(2149, 2258, 2309))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $3950$.", + "Output Answer": [ + "$2^1\\cdot 5^2\\cdot 79^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(3950))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{579,921\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 579, 921\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $905^1112 \\pmod{1916}$.", + "Output Answer": [ + "$1453$" + ], + "Output Program": [ + "print(pow(905, 1112, 1916))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8636$ is divisible by $17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8636 % 17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $388$ to base $29$.", + "Output Answer": [ + "$\\text{db}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 388\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n71645", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71645))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{18}$\n$x \\equiv 17 \\pmod{7}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 18), (17, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 18), (17, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 18), (17, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2924}{11827}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{142015373}-1462}{11827}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2924/11827)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2482^1053 \\pmod{2819}$.", + "Output Answer": [ + "$2632$" + ], + "Output Program": [ + "print(pow(2482, 1053, 2819))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $931x \\equiv 1 \\pmod{2257}$.", + "Output Answer": [ + "$2177$" + ], + "Output Program": [ + "print(pow(931, -1, 2257))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 10 \\pmod{7}$", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 20), (10, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 20), (10, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 20), (10, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45398)$.", + "Output Answer": [ + "$22698$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45398))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $33594$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(33594 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $503^m \\equiv 1 \\pmod{560}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(503, 560))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1655$ to base $5$.", + "Output Answer": [ + "$23110_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1655\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $323^m \\equiv 1 \\pmod{871}$.", + "Output Answer": [ + "$132$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(323, 871))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.394_{20}$ to base 10.", + "Output Answer": [ + "$0.173$" + ], + "Output Program": [ + "n = '0.394'.strip('.')\nbase = 20\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $863$ is divisible by $33$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(863 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $44^m \\equiv 1 \\pmod{83}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(44, 83))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-693,74,95\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -693, 74, 95\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70240 \\pmod{28}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(70240 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n45331", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(45331))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28141)$.", + "Output Answer": [ + "$27772$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28141))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-595,99\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -595, 99\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2345^1519 \\pmod{2977}$.", + "Output Answer": [ + "$2205$" + ], + "Output Program": [ + "print(pow(2345, 1519, 2977))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1217x \\equiv 1 \\pmod{2104}$.", + "Output Answer": [ + "$1001$" + ], + "Output Program": [ + "print(pow(1217, -1, 2104))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{18}$\n$x \\equiv 14 \\pmod{13}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 18), (14, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 18), (14, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 18), (14, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8720$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8720 % 16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29210 \\pmod{31}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(29210 % 31)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{10}$\n$x \\equiv 3 \\pmod{16}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 10), (3, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 10), (3, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{572,-430,193\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 572, -430, 193\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n89999", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89999))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{269}{700}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2032361}-269}{1400}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(269/700)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34636)$.", + "Output Answer": [ + "$14832$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34636))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $493^m \\equiv 1 \\pmod{517}$.", + "Output Answer": [ + "$230$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(493, 517))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2769)$.", + "Output Answer": [ + "$1680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2769))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20978)$.", + "Output Answer": [ + "$9856$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20978))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $29x \\equiv 1 \\pmod{90}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(pow(29, -1, 90))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4368)$.", + "Output Answer": [ + "$1152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4368))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $77004$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(77004 % 46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $787x \\equiv 1 \\pmod{803}$.", + "Output Answer": [ + "$552$" + ], + "Output Program": [ + "print(pow(787, -1, 803))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1855$ to base $11$.", + "Output Answer": [ + "$1437_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1855\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24789)$.", + "Output Answer": [ + "$16524$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24789))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $123$ to base $13$.", + "Output Answer": [ + "$96_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 123\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1989^118 \\pmod{2501}$.", + "Output Answer": [ + "$906$" + ], + "Output Program": [ + "print(pow(1989, 118, 2501))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21090)$.", + "Output Answer": [ + "$5184$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21090))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44776 \\pmod{34}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(44776 % 34)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{747,-603,205\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 747, -603, 205\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2719)$.", + "Output Answer": [ + "$2718$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2719))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $130^m \\equiv 1 \\pmod{339}$.", + "Output Answer": [ + "$112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(130, 339))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23019 \\pmod{94}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "print(23019 % 94)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-152$ is divisible by $2$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-152 % 2 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{815,253\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 815, 253\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n6983", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6983))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{13}$\n$x \\equiv 16 \\pmod{12}$", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "constraints = (1, 13), (16, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 13), (16, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 13), (16, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40773)$.", + "Output Answer": [ + "$27180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40773))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.646$ to base $16$.", + "Output Answer": [ + "$\\text{0.a5604}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.646\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $115^m \\equiv 1 \\pmod{539}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(115, 539))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-990,268\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -990, 268\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1579x \\equiv 1 \\pmod{1647}$.", + "Output Answer": [ + "$1429$" + ], + "Output Program": [ + "print(pow(1579, -1, 1647))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 1 \\pmod{19}$\n$x \\equiv 1 \\pmod{18}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 17), (1, 19), (1, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 17), (1, 19), (1, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 17), (1, 19), (1, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $725^2308 \\pmod{929}$.", + "Output Answer": [ + "$440$" + ], + "Output Program": [ + "print(pow(725, 2308, 929))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19045}{22797}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2441524861}-19045}{45594}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19045/22797)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n88605", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(88605))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $575^m \\equiv 1 \\pmod{583}$.", + "Output Answer": [ + "$260$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(575, 583))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{43}{70}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{140} \\left(\\sqrt{21449}-43\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(43/70)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-6441$ is divisible by $19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6441 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n70237", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70237))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $96456$.", + "Output Answer": [ + "$2^3\\cdot 3^1\\cdot 4019^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(96456))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 83125 \\pmod{14}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(83125 % 14)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 5 \\pmod{9}$\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 18 \\pmod{19}$", + "Output Answer": [ + "$10544$" + ], + "Output Program": [ + "constraints = (16, 4), (5, 9), (4, 17), (18, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 4), (5, 9), (4, 17), (18, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 4), (5, 9), (4, 17), (18, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $496$ to base $34$.", + "Output Answer": [ + "$\\text{ek}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 496\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $167^m \\equiv 1 \\pmod{632}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(167, 632))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $10193$.", + "Output Answer": [ + "$\\{3,5,11,12,17,20,21,22,24,27\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(10193):\n if len(roots) == 10: break\n if gcd(a, 10193) == 1 and is_primitive_root(a, 10193):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92434 \\pmod{7}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(92434 % 7)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67430 \\pmod{72}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(67430 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{285,-964\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 285, -964\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{205,278,-895\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 205, 278, -895\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n104729", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(104729))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1192^1294 \\pmod{1760}$.", + "Output Answer": [ + "$1664$" + ], + "Output Program": [ + "print(pow(1192, 1294, 1760))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $698$ to base $33$.", + "Output Answer": [ + "$\\text{l5}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 698\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1785^1922 \\pmod{2179}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(pow(1785, 1922, 2179))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $53^m \\equiv 1 \\pmod{777}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(53, 777))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53035 \\pmod{51}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(53035 % 51)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96798 \\pmod{80}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "print(96798 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $29017$.", + "Output Answer": [ + "$\\{5,10,15,23,30,33,35,40,41,46\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(29017):\n if len(roots) == 10: break\n if gcd(a, 29017) == 1 and is_primitive_root(a, 29017):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-866,-906\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -866, -906\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1224^786 \\pmod{2758}$.", + "Output Answer": [ + "$582$" + ], + "Output Program": [ + "print(pow(1224, 786, 2758))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77006 \\pmod{76}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(77006 % 76)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n85305", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(85305))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34386)$.", + "Output Answer": [ + "$10400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34386))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1101$ is divisible by $40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1101 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5337}{9167}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{14584765}-5337}{18334}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5337/9167)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{17}$\n$x \\equiv 12 \\pmod{4}$\n$x \\equiv 12 \\pmod{8}$\n$x \\equiv 4 \\pmod{2}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 17), (12, 4), (12, 8), (4, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 17), (12, 4), (12, 8), (4, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38422)$.", + "Output Answer": [ + "$19210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38422))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $1^m \\equiv 1 \\pmod{764}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(1, 764))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{14}$\n$x \\equiv 5 \\pmod{15}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 14), (5, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 14), (5, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 14), (5, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76300 \\pmod{76}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "print(76300 % 76)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $624_{17}$ to base 10.", + "Output Answer": [ + "$1772$" + ], + "Output Program": [ + "n = '624'.strip('.')\nbase = 17\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1741^531 \\pmod{2464}$.", + "Output Answer": [ + "$1301$" + ], + "Output Program": [ + "print(pow(1741, 531, 2464))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $29^m \\equiv 1 \\pmod{421}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(29, 421))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3319}{13703}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{762104597}-3319}{27406}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3319/13703)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $838$.", + "Output Answer": [ + "$\\{11,17,19,31,33,51,53,55,57,61\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(838):\n if len(roots) == 10: break\n if gcd(a, 838) == 1 and is_primitive_root(a, 838):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{447}$.", + "Output Answer": [ + "$148$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 447))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76473 \\pmod{67}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(76473 % 67)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $353^m \\equiv 1 \\pmod{576}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(353, 576))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 2 \\pmod{8}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (2, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 11), (2, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 11), (2, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73457 \\pmod{60}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(73457 % 60)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1310^476 \\pmod{2144}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "print(pow(1310, 476, 2144))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 3 \\pmod{7}$\n$x \\equiv 15 \\pmod{17}$\n$x \\equiv 17 \\pmod{11}$", + "Output Answer": [ + "$1018$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 2), (3, 7), (15, 17), (17, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 2), (3, 7), (15, 17), (17, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 2), (3, 7), (15, 17), (17, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $411^m \\equiv 1 \\pmod{508}$.", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(411, 508))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-865,149,678\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -865, 149, 678\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48929)$.", + "Output Answer": [ + "$48384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48929))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15}{118}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{236} \\left(\\sqrt{55921}-15\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15/118)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $794$ is divisible by $37$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(794 % 37 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{320,-586\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 320, -586\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n48617", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(48617))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1263x \\equiv 1 \\pmod{1879}$.", + "Output Answer": [ + "$485$" + ], + "Output Program": [ + "print(pow(1263, -1, 1879))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17016)$.", + "Output Answer": [ + "$5664$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17016))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-141$ is divisible by $9$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-141 % 9 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $265x \\equiv 1 \\pmod{2086}$.", + "Output Answer": [ + "$307$" + ], + "Output Program": [ + "print(pow(265, -1, 2086))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{78}{3125}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9767146}-39}{3125}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(78/3125)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1362$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1362 % -41 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $77^m \\equiv 1 \\pmod{127}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(77, 127))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8079)$.", + "Output Answer": [ + "$5384$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8079))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{11}{92}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{184} \\left(\\sqrt{33977}-11\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11/92)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n60607", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60607))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 6 \\pmod{16}$", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "import math\n\nconstraints = (15, 11), (6, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 11), (6, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 11), (6, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-500,-554,301\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -500, -554, 301\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{2}$\n$x \\equiv 5 \\pmod{9}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 2), (5, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 2), (5, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (1, 2), (5, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $368^115 \\pmod{1143}$.", + "Output Answer": [ + "$683$" + ], + "Output Program": [ + "print(pow(368, 115, 1143))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1246$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1246 % -45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{584,948\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 584, 948\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $67763$.", + "Output Answer": [ + "$67763^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(67763))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1491^321 \\pmod{2324}$.", + "Output Answer": [ + "$1099$" + ], + "Output Program": [ + "print(pow(1491, 321, 2324))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{474,82,441\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 474, 82, 441\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n101401", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101401))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32902)$.", + "Output Answer": [ + "$16450$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32902))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{14}$\n$x \\equiv 10 \\pmod{12}$", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "constraints = (2, 14), (10, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 14), (10, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $29590$ is divisible by $44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(29590 % 44 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n40387", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(40387))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $4x \\equiv 1 \\pmod{9}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(4, -1, 9))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $9252$ is divisible by $-36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(9252 % -36 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-138$ is divisible by $-2$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-138 % -2 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{24143}{25274}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3137984753}-24143}{50548}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24143/25274)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-17061$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-17061 % 47 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4661}{5826}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{6299761}-4661}{11652}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4661/5826)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n87581", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(87581))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70656 \\pmod{55}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(70656 % 55)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $391x \\equiv 1 \\pmod{550}$.", + "Output Answer": [ + "$211$" + ], + "Output Program": [ + "print(pow(391, -1, 550))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $231_{26}$ to base 10.", + "Output Answer": [ + "$1431$" + ], + "Output Program": [ + "n = '231'.strip('.')\nbase = 26\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21867)$.", + "Output Answer": [ + "$14112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21867))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1882^2246 \\pmod{2470}$.", + "Output Answer": [ + "$2414$" + ], + "Output Program": [ + "print(pow(1882, 2246, 2470))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $262$ to base $7$.", + "Output Answer": [ + "$523_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 262\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1864^1571 \\pmod{2066}$.", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "print(pow(1864, 1571, 2066))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-976,781,-340\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -976, 781, -340\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2165$ to base $21$.", + "Output Answer": [ + "$\\text{4j2}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2165\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{43815}{16033}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2947982581}-43815}{32066}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(43815/16033)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36248)$.", + "Output Answer": [ + "$17248$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36248))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{11}$\n$x \\equiv 20 \\pmod{20}$\n$x \\equiv 8 \\pmod{16}$\n$x \\equiv 1 \\pmod{19}$", + "Output Answer": [ + "$8760$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 11), (20, 20), (8, 16), (1, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 11), (20, 20), (8, 16), (1, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $277^m \\equiv 1 \\pmod{574}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(277, 574))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $300x \\equiv 1 \\pmod{2299}$.", + "Output Answer": [ + "$774$" + ], + "Output Program": [ + "print(pow(300, -1, 2299))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.001110010001011010001_2$ to base 10.", + "Output Answer": [ + "$0.223$" + ], + "Output Program": [ + "n = '0.001110010001011010001'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2667}{2567}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{33470845}-2667}{5134}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2667/2567)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25339)$.", + "Output Answer": [ + "$25338$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25339))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{770,-632\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 770, -632\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $60029$.", + "Output Answer": [ + "$\\{2,3,8,10,11,12,13,14,15,18\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(60029):\n if len(roots) == 10: break\n if gcd(a, 60029) == 1 and is_primitive_root(a, 60029):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n75767", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(75767))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{589,-77\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 589, -77\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7497}{12218}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{653323105}-7497}{24436}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7497/12218)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n53595", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53595))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2481^269 \\pmod{2721}$.", + "Output Answer": [ + "$1371$" + ], + "Output Program": [ + "print(pow(2481, 269, 2721))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $14304$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(14304 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-326,157,-917\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -326, 157, -917\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $170^m \\equiv 1 \\pmod{559}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(170, 559))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{242,-55\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 242, -55\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1004x \\equiv 1 \\pmod{2159}$.", + "Output Answer": [ + "$1344$" + ], + "Output Program": [ + "print(pow(1004, -1, 2159))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92701 \\pmod{6}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(92701 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2071x \\equiv 1 \\pmod{2082}$.", + "Output Answer": [ + "$757$" + ], + "Output Program": [ + "print(pow(2071, -1, 2082))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $19x \\equiv 1 \\pmod{463}$.", + "Output Answer": [ + "$195$" + ], + "Output Program": [ + "print(pow(19, -1, 463))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4208}{25271}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{643050257}-2104}{25271}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4208/25271)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1852$ to base $32$.", + "Output Answer": [ + "$\\text{1ps}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1852\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $40^1609 \\pmod{508}$.", + "Output Answer": [ + "$264$" + ], + "Output Program": [ + "print(pow(40, 1609, 508))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15567)$.", + "Output Answer": [ + "$10376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15567))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-7$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-7 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $295^415 \\pmod{1491}$.", + "Output Answer": [ + "$673$" + ], + "Output Program": [ + "print(pow(295, 415, 1491))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{46,-848,-871\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 46, -848, -871\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-634,364,-667\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -634, 364, -667\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9621)$.", + "Output Answer": [ + "$6408$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9621))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1453^33 \\pmod{1562}$.", + "Output Answer": [ + "$991$" + ], + "Output Program": [ + "print(pow(1453, 33, 1562))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41763 \\pmod{16}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(41763 % 16)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $11322$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(11322 % -34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{13}$\n$x \\equiv 13 \\pmod{6}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "import math\n\nconstraints = (7, 13), (13, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 13), (13, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 13), (13, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{19}$\n$x \\equiv 8 \\pmod{12}$", + "Output Answer": [ + "$212$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 19), (8, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 19), (8, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 19), (8, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-554,-598\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -554, -598\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-278$ is divisible by $6$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-278 % 6 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-550,-111\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -550, -111\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n70769", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(70769))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{208,-570,213\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 208, -570, 213\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65696 \\pmod{84}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(65696 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10027 \\pmod{8}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(10027 % 8)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{740}{1773}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3280429}-370}{1773}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(740/1773)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $993^458 \\pmod{2800}$.", + "Output Answer": [ + "$449$" + ], + "Output Program": [ + "print(pow(993, 458, 2800))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1123x \\equiv 1 \\pmod{2156}$.", + "Output Answer": [ + "$551$" + ], + "Output Program": [ + "print(pow(1123, -1, 2156))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{7}$\n$x \\equiv 7 \\pmod{9}$", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 7), (7, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 7), (7, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 7), (7, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12327}{11692}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{698766385}-12327}{23384}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12327/11692)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31883)$.", + "Output Answer": [ + "$31882$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31883))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2077^2384 \\pmod{2441}$.", + "Output Answer": [ + "$1172$" + ], + "Output Program": [ + "print(pow(2077, 2384, 2441))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1952x \\equiv 1 \\pmod{2431}$.", + "Output Answer": [ + "$878$" + ], + "Output Program": [ + "print(pow(1952, -1, 2431))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14373)$.", + "Output Answer": [ + "$9576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14373))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-173,-737\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -173, -737\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-51,-592\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -51, -592\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-315,661\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -315, 661\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.511$ to base $36$.", + "Output Answer": [ + "$\\text{0.ie98}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.511\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{33308}{2921}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{285887957}-16654}{2921}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33308/2921)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10362)$.", + "Output Answer": [ + "$3120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10362))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $335x \\equiv 1 \\pmod{468}$.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "print(pow(335, -1, 468))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17936)$.", + "Output Answer": [ + "$8352$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17936))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1656$ is divisible by $-6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1656 % -6 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{49,-340,45\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 49, -340, 45\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $58013$.", + "Output Answer": [ + "$\\{2,3,5,8,11,12,13,14,18,20\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(58013):\n if len(roots) == 10: break\n if gcd(a, 58013) == 1 and is_primitive_root(a, 58013):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $18x \\equiv 1 \\pmod{343}$.", + "Output Answer": [ + "$324$" + ], + "Output Program": [ + "print(pow(18, -1, 343))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $7868$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7868 % 14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 10 \\pmod{17}$\n$x \\equiv 16 \\pmod{12}$", + "Output Answer": [ + "$520$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 5), (10, 17), (16, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 5), (10, 17), (16, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (10, 17), (16, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28677)$.", + "Output Answer": [ + "$17160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28677))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 8272 \\pmod{2}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(8272 % 2)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $876$ to base $24$.", + "Output Answer": [ + "$\\text{1cc}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 876\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(365)$.", + "Output Answer": [ + "$288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(365))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $945x \\equiv 1 \\pmod{2479}$.", + "Output Answer": [ + "$383$" + ], + "Output Program": [ + "print(pow(945, -1, 2479))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33307)$.", + "Output Answer": [ + "$31536$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33307))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26752 \\pmod{87}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(26752 % 87)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{17}$\n$x \\equiv 12 \\pmod{19}$", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "constraints = (3, 17), (12, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 17), (12, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (3, 17), (12, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1551^1255 \\pmod{1591}$.", + "Output Answer": [ + "$192$" + ], + "Output Program": [ + "print(pow(1551, 1255, 1591))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37924)$.", + "Output Answer": [ + "$17928$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37924))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10902)$.", + "Output Answer": [ + "$3432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10902))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $49261$.", + "Output Answer": [ + "$\\{2,10,14,17,18,22,29,30,37,42\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(49261):\n if len(roots) == 10: break\n if gcd(a, 49261) == 1 and is_primitive_root(a, 49261):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $527x \\equiv 1 \\pmod{975}$.", + "Output Answer": [ + "$938$" + ], + "Output Program": [ + "print(pow(527, -1, 975))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6271}{6324}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{199297345}-6271}{12648}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6271/6324)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $263^m \\equiv 1 \\pmod{702}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(263, 702))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78885 \\pmod{52}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(78885 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-40388$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-40388 % 46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{509}{3776}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{57291785}-509}{7552}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(509/3776)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47051 \\pmod{37}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(47051 % 37)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57960 \\pmod{55}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(57960 % 55)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $610$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(610 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1790$ to base $17$.", + "Output Answer": [ + "$635_{17}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 17\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1790\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2560}{489}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{489} \\left(\\sqrt{1877521}-1280\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2560/489)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{2}$\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 1 \\pmod{11}$", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 2), (6, 5), (1, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 2), (6, 5), (1, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 2), (6, 5), (1, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15979}{10505}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{696748541}-15979}{21010}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15979/10505)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $662^2356 \\pmod{1099}$.", + "Output Answer": [ + "$403$" + ], + "Output Program": [ + "print(pow(662, 2356, 1099))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n54493", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54493))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-2800$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2800 % -14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{0,-1,-3,1\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = 0, -1, -3, 1\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $919x \\equiv 1 \\pmod{1134}$.", + "Output Answer": [ + "$865$" + ], + "Output Program": [ + "print(pow(919, -1, 1134))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{13}$\n$x \\equiv 15 \\pmod{10}$\n$x \\equiv 19 \\pmod{16}$\n$x \\equiv 11 \\pmod{14}$", + "Output Answer": [ + "$4435$" + ], + "Output Program": [ + "constraints = (2, 13), (15, 10), (19, 16), (11, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 13), (15, 10), (19, 16), (11, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $86^m \\equiv 1 \\pmod{123}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(86, 123))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $786^42 \\pmod{1584}$.", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "print(pow(786, 42, 1584))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n60869", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60869))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 77745 \\pmod{18}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(77745 % 18)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-47240$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-47240 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n41189", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(41189))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-29274$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-29274 % -42 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $7954$.", + "Output Answer": [ + "$2^1\\cdot 41^1\\cdot 97^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(7954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $2556$ is divisible by $36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2556 % 36 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 8 \\pmod{5}$", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "constraints = (9, 14), (8, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (8, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 14), (8, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96827 \\pmod{31}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(96827 % 31)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19935 \\pmod{74}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(19935 % 74)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1377x \\equiv 1 \\pmod{1480}$.", + "Output Answer": [ + "$273$" + ], + "Output Program": [ + "print(pow(1377, -1, 1480))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2788$ to base $21$.", + "Output Answer": [ + "$\\text{66g}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2788\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13266)$.", + "Output Answer": [ + "$3960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13266))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $475^80 \\pmod{922}$.", + "Output Answer": [ + "$861$" + ], + "Output Program": [ + "print(pow(475, 80, 922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{4}$\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 10 \\pmod{17}$\n$x \\equiv 1 \\pmod{8}$", + "Output Answer": [ + "$129$" + ], + "Output Program": [ + "constraints = (13, 4), (9, 5), (10, 17), (1, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 4), (9, 5), (10, 17), (1, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-4884$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-4884 % -33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-409,269\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -409, 269\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $165x \\equiv 1 \\pmod{1007}$.", + "Output Answer": [ + "$592$" + ], + "Output Program": [ + "print(pow(165, -1, 1007))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n24121", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24121))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n93103", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(93103))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54354 \\pmod{8}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(54354 % 8)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $525^m \\equiv 1 \\pmod{823}$.", + "Output Answer": [ + "$411$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(525, 823))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n5019", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5019))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2426^2067 \\pmod{2487}$.", + "Output Answer": [ + "$206$" + ], + "Output Program": [ + "print(pow(2426, 2067, 2487))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $691^m \\equiv 1 \\pmod{726}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(691, 726))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $718$.", + "Output Answer": [ + "$\\{7,13,19,21,29,31,35,39,43,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(718):\n if len(roots) == 10: break\n if gcd(a, 718) == 1 and is_primitive_root(a, 718):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44700)$.", + "Output Answer": [ + "$11840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44700))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{17}$\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 19 \\pmod{2}$", + "Output Answer": [ + "$99$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 17), (4, 5), (19, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 17), (4, 5), (19, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 17), (4, 5), (19, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $265^1627 \\pmod{1954}$.", + "Output Answer": [ + "$429$" + ], + "Output Program": [ + "print(pow(265, 1627, 1954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $457^m \\equiv 1 \\pmod{577}$.", + "Output Answer": [ + "$576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(457, 577))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10728)$.", + "Output Answer": [ + "$3552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10728))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37372)$.", + "Output Answer": [ + "$18684$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37372))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $321x \\equiv 1 \\pmod{485}$.", + "Output Answer": [ + "$346$" + ], + "Output Program": [ + "print(pow(321, -1, 485))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7329}{1832}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{397273}-7329}{3664}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7329/1832)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 14 \\pmod{10}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 3), (14, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 3), (14, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 3), (14, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22522 \\pmod{26}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(22522 % 26)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{30305}{14929}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1809893189}-30305}{29858}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30305/14929)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{9}$\n$x \\equiv 6 \\pmod{13}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$136$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 9), (6, 13), (11, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 9), (6, 13), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 9), (6, 13), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $76491$.", + "Output Answer": [ + "$3^3\\cdot 2833^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(76491))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $39372$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(39372 % -34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4103}{9408}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{370876465}-4103}{18816}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4103/9408)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2115^1672 \\pmod{2319}$.", + "Output Answer": [ + "$783$" + ], + "Output Program": [ + "print(pow(2115, 1672, 2319))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75225 \\pmod{70}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(75225 % 70)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-276,56\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -276, 56\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1843}{12108}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{589811305}-1843}{24216}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1843/12108)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $930^394 \\pmod{1803}$.", + "Output Answer": [ + "$894$" + ], + "Output Program": [ + "print(pow(930, 394, 1803))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 5470 \\pmod{30}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(5470 % 30)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $715^m \\equiv 1 \\pmod{978}$.", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(715, 978))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $135$ to base $6$.", + "Output Answer": [ + "$343_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 135\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n79149", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(79149))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2204$ to base $14$.", + "Output Answer": [ + "$\\text{b36}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2204\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $815x \\equiv 1 \\pmod{834}$.", + "Output Answer": [ + "$395$" + ], + "Output Program": [ + "print(pow(815, -1, 834))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $65664$.", + "Output Answer": [ + "$2^7\\cdot 3^3\\cdot 19^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(65664))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-266,241,-873\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -266, 241, -873\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{42683}{2335}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1843647389}-42683}{4670}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(42683/2335)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1176$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1176 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $486^m \\equiv 1 \\pmod{851}$.", + "Output Answer": [ + "$396$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(486, 851))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43294)$.", + "Output Answer": [ + "$21646$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43294))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22324)$.", + "Output Answer": [ + "$11160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22324))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{376,-388\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = 376, -388\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $397^m \\equiv 1 \\pmod{858}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(397, 858))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21092)$.", + "Output Answer": [ + "$10544$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21092))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $46129$.", + "Output Answer": [ + "$163^1\\cdot 283^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(46129))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{387,841,772\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 387, 841, 772\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{702,247,464\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 702, 247, 464\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $941^1990 \\pmod{2717}$.", + "Output Answer": [ + "$1871$" + ], + "Output Program": [ + "print(pow(941, 1990, 2717))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{355,-277\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 355, -277\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $410^m \\equiv 1 \\pmod{539}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(410, 539))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $224^m \\equiv 1 \\pmod{521}$.", + "Output Answer": [ + "$520$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(224, 521))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2465^448 \\pmod{2743}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(2465, 448, 2743))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 11 \\pmod{12}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 11), (11, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 11), (11, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (11, 11), (11, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{815,-844\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 815, -844\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3810$ is divisible by $10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3810 % 10 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{791,-8,797\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 791, -8, 797\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30090 \\pmod{10}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(30090 % 10)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70383 \\pmod{67}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(70383 % 67)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $227^m \\equiv 1 \\pmod{510}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(227, 510))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $299x \\equiv 1 \\pmod{393}$.", + "Output Answer": [ + "$347$" + ], + "Output Program": [ + "print(pow(299, -1, 393))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 16 \\pmod{5}$", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "constraints = (16, 10), (14, 7), (16, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 10), (14, 7), (16, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $205^m \\equiv 1 \\pmod{454}$.", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(205, 454))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37260)$.", + "Output Answer": [ + "$9504$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37260))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{3}$\n$x \\equiv 5 \\pmod{13}$", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 3), (5, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 3), (5, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 3), (5, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{5}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 5), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 5), (10, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 5), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-39$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-39 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1270^718 \\pmod{1893}$.", + "Output Answer": [ + "$562$" + ], + "Output Program": [ + "print(pow(1270, 718, 1893))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n73183", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(73183))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4434 \\pmod{17}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(4434 % 17)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $473x \\equiv 1 \\pmod{662}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(473, -1, 662))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-2,1\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -2, 1\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84513 \\pmod{93}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "print(84513 % 93)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $491x \\equiv 1 \\pmod{2069}$.", + "Output Answer": [ + "$1399$" + ], + "Output Program": [ + "print(pow(491, -1, 2069))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1628}{1583}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3168485}-814}{1583}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1628/1583)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23154 \\pmod{26}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(23154 % 26)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $185x \\equiv 1 \\pmod{326}$.", + "Output Answer": [ + "$289$" + ], + "Output Program": [ + "print(pow(185, -1, 326))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $99$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(99 % 22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15953)$.", + "Output Answer": [ + "$13104$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15953))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-228,-966\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -228, -966\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n34727", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(34727))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1782$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1782 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{271}{139}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{278} \\left(5 \\sqrt{6029}-271\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(271/139)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{15}$\n$x \\equiv 2 \\pmod{14}$\n$x \\equiv 6 \\pmod{20}$", + "Output Answer": [ + "$226$" + ], + "Output Program": [ + "constraints = (16, 15), (2, 14), (6, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 15), (2, 14), (6, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{20472}{16501}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{377058697}-10236}{16501}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20472/16501)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15992)$.", + "Output Answer": [ + "$7992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15992))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{38044}{17291}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{660815165}-19022}{17291}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(38044/17291)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4613}{10833}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{19627813}-4613}{21666}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4613/10833)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1415$ to base $7$.", + "Output Answer": [ + "$4061_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1415\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $14586$ is divisible by $-44$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(14586 % -44 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 11 \\pmod{4}$\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 3 \\pmod{17}$", + "Output Answer": [ + "$1091$" + ], + "Output Program": [ + "constraints = (3, 8), (11, 4), (12, 13), (3, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 8), (11, 4), (12, 13), (3, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 9 \\pmod{7}$", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 17), (9, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (9, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 17), (9, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{742,717,-107\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 742, 717, -107\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2192^1130 \\pmod{2292}$.", + "Output Answer": [ + "$412$" + ], + "Output Program": [ + "print(pow(2192, 1130, 2292))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{3,-23,-571\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 3, -23, -571\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3654$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3654 % -27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n80053", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(80053))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58051 \\pmod{98}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(58051 % 98)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $68671$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(68671 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{160}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 160))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $479$ is divisible by $11$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(479 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{24657}{15898}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1618953265}-24657}{31796}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24657/15898)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n98865", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(98865))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $173^m \\equiv 1 \\pmod{263}$.", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(173, 263))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{33417}{2423}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1140179605}-33417}{4846}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33417/2423)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $135^2052 \\pmod{1456}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(135, 2052, 1456))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $366^m \\equiv 1 \\pmod{955}$.", + "Output Answer": [ + "$190$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(366, 955))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5115}{4888}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{121733401}-5115}{9776}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5115/4888)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $517^m \\equiv 1 \\pmod{694}$.", + "Output Answer": [ + "$346$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(517, 694))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $905^222 \\pmod{2142}$.", + "Output Answer": [ + "$883$" + ], + "Output Program": [ + "print(pow(905, 222, 2142))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $15299$.", + "Output Answer": [ + "$\\{2,6,7,8,10,11,13,18,19,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(15299):\n if len(roots) == 10: break\n if gcd(a, 15299) == 1 and is_primitive_root(a, 15299):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $166^1669 \\pmod{1576}$.", + "Output Answer": [ + "$832$" + ], + "Output Program": [ + "print(pow(166, 1669, 1576))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-515,282\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -515, 282\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{13087}{27979}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3302567333}-13087}{55958}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13087/27979)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{9}$\n$x \\equiv 7 \\pmod{2}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 9), (7, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 9), (7, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 9), (7, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $230x \\equiv 1 \\pmod{2019}$.", + "Output Answer": [ + "$1940$" + ], + "Output Program": [ + "print(pow(230, -1, 2019))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1012x \\equiv 1 \\pmod{1349}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(pow(1012, -1, 1349))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67435 \\pmod{39}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(67435 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-835,-940,123\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -835, -940, 123\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $366_{15}$ to base 10.", + "Output Answer": [ + "$771$" + ], + "Output Program": [ + "n = '366'.strip('.')\nbase = 15\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19148}{20543}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{20547053}-9574}{20543}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19148/20543)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1993^1907 \\pmod{2740}$.", + "Output Answer": [ + "$737$" + ], + "Output Program": [ + "print(pow(1993, 1907, 2740))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{4}$\n$x \\equiv 20 \\pmod{6}$", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "constraints = (8, 4), (20, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 4), (20, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $173^m \\equiv 1 \\pmod{866}$.", + "Output Answer": [ + "$432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(173, 866))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2764$ to base $5$.", + "Output Answer": [ + "$42024_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2764\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $75213$.", + "Output Answer": [ + "$3^2\\cdot 61^1\\cdot 137^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(75213))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{25535}{40194}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7114266769}-25535}{80388}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(25535/40194)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{987,656\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 987, 656\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-652,22,17\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -652, 22, 17\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2173^1687 \\pmod{2903}$.", + "Output Answer": [ + "$1752$" + ], + "Output Program": [ + "print(pow(2173, 1687, 2903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-854$ is divisible by $23$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-854 % 23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16054)$.", + "Output Answer": [ + "$7656$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16054))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{12}$\n$x \\equiv 10 \\pmod{15}$\n$x \\equiv 13 \\pmod{17}$", + "Output Answer": [ + "$880$" + ], + "Output Program": [ + "constraints = (16, 12), (10, 15), (13, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 12), (10, 15), (13, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $89^m \\equiv 1 \\pmod{696}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(89, 696))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n17497", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(17497))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1368^2144 \\pmod{2488}$.", + "Output Answer": [ + "$1272$" + ], + "Output Program": [ + "print(pow(1368, 2144, 2488))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78202 \\pmod{30}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(78202 % 30)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{7}$\n$x \\equiv 15 \\pmod{16}$", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (5, 7), (15, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 7), (15, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (5, 7), (15, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{13}$\n$x \\equiv 13 \\pmod{8}$\n$x \\equiv 0 \\pmod{19}$\n$x \\equiv 9 \\pmod{18}$", + "Output Answer": [ + "$1197$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 13), (13, 8), (0, 19), (9, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 13), (13, 8), (0, 19), (9, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37445 \\pmod{79}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "print(37445 % 79)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{345,598\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 345, 598\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{21447}{23440}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2657708209}-21447}{46880}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21447/23440)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-364,-314,-405\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -364, -314, -405\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74533 \\pmod{71}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(74533 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3269}{2088}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{28125337}-3269}{4176}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3269/2088)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6466}{5045}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{35904314}-3233}{5045}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6466/5045)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89096 \\pmod{19}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(89096 % 19)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-411$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-411 % -3 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{17}$\n$x \\equiv 2 \\pmod{9}$\n$x \\equiv 5 \\pmod{6}$\n$x \\equiv 20 \\pmod{13}$", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 17), (2, 9), (5, 6), (20, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 17), (2, 9), (5, 6), (20, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43967 \\pmod{95}$.", + "Output Answer": [ + "$77$" + ], + "Output Program": [ + "print(43967 % 95)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $41x \\equiv 1 \\pmod{921}$.", + "Output Answer": [ + "$629$" + ], + "Output Program": [ + "print(pow(41, -1, 921))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{571,386,335\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 571, 386, 335\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $502^m \\equiv 1 \\pmod{657}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(502, 657))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1176$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1176 % 42 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n53771", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53771))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{23787}{8651}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{865180573}-23787}{17302}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23787/8651)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3168)$.", + "Output Answer": [ + "$960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3168))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46496)$.", + "Output Answer": [ + "$23232$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46496))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8645$ is divisible by $35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8645 % 35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $51439$.", + "Output Answer": [ + "$\\{3,6,11,13,15,17,19,22,24,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(51439):\n if len(roots) == 10: break\n if gcd(a, 51439) == 1 and is_primitive_root(a, 51439):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37424)$.", + "Output Answer": [ + "$18704$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37424))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{3}$\n$x \\equiv 18 \\pmod{5}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nconstraints = (18, 3), (18, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 3), (18, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 3), (18, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{33267}{40790}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7761989689}-33267}{81580}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(33267/40790)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{126,505,-728\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 126, 505, -728\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75467 \\pmod{3}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(75467 % 3)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $661^18 \\pmod{1978}$.", + "Output Answer": [ + "$1337$" + ], + "Output Program": [ + "print(pow(661, 18, 1978))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $90^2041 \\pmod{1037}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "print(pow(90, 2041, 1037))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 42190 \\pmod{53}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(42190 % 53)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1000$ to base $34$.", + "Output Answer": [ + "$\\text{te}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1000\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{11,-792,376\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 11, -792, 376\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1542^1890 \\pmod{1993}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "print(pow(1542, 1890, 1993))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 33915 \\pmod{30}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(33915 % 30)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14821)$.", + "Output Answer": [ + "$14820$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14821))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{272,-110\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 272, -110\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $605^m \\equiv 1 \\pmod{943}$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(605, 943))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{6}$\n$x \\equiv 7 \\pmod{10}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 6), (7, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 6), (7, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{16}$\n$x \\equiv 18 \\pmod{18}$\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 12 \\pmod{6}$", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 16), (18, 18), (15, 3), (12, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 16), (18, 18), (15, 3), (12, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2646$ to base $34$.", + "Output Answer": [ + "$\\text{29s}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2646\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-950,-511\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -950, -511\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14152 \\pmod{11}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(14152 % 11)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1218^355 \\pmod{1725}$.", + "Output Answer": [ + "$1632$" + ], + "Output Program": [ + "print(pow(1218, 355, 1725))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1626^1240 \\pmod{2300}$.", + "Output Answer": [ + "$1576$" + ], + "Output Program": [ + "print(pow(1626, 1240, 2300))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 871 \\pmod{24}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(871 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-22078$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-22078 % -38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11420)$.", + "Output Answer": [ + "$4560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11420))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-780$ is divisible by $-13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-780 % -13 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $17^m \\equiv 1 \\pmod{260}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(17, 260))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $395x \\equiv 1 \\pmod{601}$.", + "Output Answer": [ + "$318$" + ], + "Output Program": [ + "print(pow(395, -1, 601))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55459 \\pmod{11}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(55459 % 11)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-22,-700,570\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -22, -700, 570\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.19$ to base $33$.", + "Output Answer": [ + "$\\text{0.68u1}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.19\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $433x \\equiv 1 \\pmod{1592}$.", + "Output Answer": [ + "$489$" + ], + "Output Program": [ + "print(pow(433, -1, 1592))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-861,-128\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -861, -128\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $333x \\equiv 1 \\pmod{976}$.", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "print(pow(333, -1, 976))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $15x \\equiv 1 \\pmod{52}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(pow(15, -1, 52))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3473}{6512}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{181686305}-3473}{13024}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3473/6512)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 28357 \\pmod{19}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(28357 % 19)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1516^1609 \\pmod{1604}$.", + "Output Answer": [ + "$396$" + ], + "Output Program": [ + "print(pow(1516, 1609, 1604))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $34449$.", + "Output Answer": [ + "$3^1\\cdot 11483^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(34449))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-281,50,-637\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -281, 50, -637\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $42538$.", + "Output Answer": [ + "$\\{3,7,11,15,23,27,29,31,35,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(42538):\n if len(roots) == 10: break\n if gcd(a, 42538) == 1 and is_primitive_root(a, 42538):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-26400$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-26400 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $6$ is divisible by $-3$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6 % -3 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{19}$\n$x \\equiv 20 \\pmod{20}$\n$x \\equiv 4 \\pmod{17}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$51480$" + ], + "Output Program": [ + "constraints = (9, 19), (20, 20), (4, 17), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 19), (20, 20), (4, 17), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 19), (20, 20), (4, 17), (13, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(814)$.", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(814))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $135x \\equiv 1 \\pmod{832}$.", + "Output Answer": [ + "$567$" + ], + "Output Program": [ + "print(pow(135, -1, 832))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1698^1981 \\pmod{1733}$.", + "Output Answer": [ + "$282$" + ], + "Output Program": [ + "print(pow(1698, 1981, 1733))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $499x \\equiv 1 \\pmod{1479}$.", + "Output Answer": [ + "$904$" + ], + "Output Program": [ + "print(pow(499, -1, 1479))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50474 \\pmod{48}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(50474 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6200}{13607}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{194760449}-3100}{13607}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6200/13607)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $753x \\equiv 1 \\pmod{2422}$.", + "Output Answer": [ + "$1367$" + ], + "Output Program": [ + "print(pow(753, -1, 2422))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80687 \\pmod{24}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(80687 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-43329$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-43329 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $7^m \\equiv 1 \\pmod{289}$.", + "Output Answer": [ + "$272$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(7, 289))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{54,-887,-187\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 54, -887, -187\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.084$ to base $27$.", + "Output Answer": [ + "$\\text{0.276a}_{27}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 27\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.084\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49573)$.", + "Output Answer": [ + "$48928$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49573))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $245^m \\equiv 1 \\pmod{468}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(245, 468))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30538)$.", + "Output Answer": [ + "$15268$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30538))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $67650$ is divisible by $41$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(67650 % 41 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-66,785\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -66, 785\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{96,95,-937\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 96, 95, -937\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{472}$.", + "Output Answer": [ + "$421$" + ], + "Output Program": [ + "print(pow(37, -1, 472))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-12521$ is divisible by $-19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-12521 % -19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3337)$.", + "Output Answer": [ + "$3220$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3337))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3186}{4679}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{24430690}-1593}{4679}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3186/4679)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69510 \\pmod{23}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(69510 % 23)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2735$ to base $6$.", + "Output Answer": [ + "$20355_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2735\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2287^266 \\pmod{2621}$.", + "Output Answer": [ + "$1870$" + ], + "Output Program": [ + "print(pow(2287, 266, 2621))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17625}{19772}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1874368561}-17625}{39544}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17625/19772)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-7024$ is divisible by $16$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-7024 % 16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n79825", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(79825))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $232^m \\equiv 1 \\pmod{651}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(232, 651))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $547x \\equiv 1 \\pmod{1764}$.", + "Output Answer": [ + "$1219$" + ], + "Output Program": [ + "print(pow(547, -1, 1764))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 62459 \\pmod{18}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(62459 % 18)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{278,-773,362\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 278, -773, 362\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9075)$.", + "Output Answer": [ + "$4400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9075))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $131^m \\equiv 1 \\pmod{212}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(131, 212))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-5124$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-5124 % 14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(26799)$.", + "Output Answer": [ + "$17864$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(26799))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1153^1353 \\pmod{2183}$.", + "Output Answer": [ + "$1042$" + ], + "Output Program": [ + "print(pow(1153, 1353, 2183))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15047 \\pmod{74}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(15047 % 74)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 5 \\pmod{19}$\n$x \\equiv 9 \\pmod{17}$", + "Output Answer": [ + "$6503$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 2), (13, 11), (5, 19), (9, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 2), (13, 11), (5, 19), (9, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 2), (13, 11), (5, 19), (9, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{9}$\n$x \\equiv 0 \\pmod{5}$\n$x \\equiv 2 \\pmod{2}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 9), (0, 5), (2, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 9), (0, 5), (2, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (0, 9), (0, 5), (2, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54705 \\pmod{53}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(54705 % 53)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $62456$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(62456 % 37 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1245}{2062}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18557401}-1245}{4124}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1245/2062)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80948 \\pmod{82}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(80948 % 82)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 18 \\pmod{5}$\n$x \\equiv 9 \\pmod{2}$\n$x \\equiv 15 \\pmod{16}$", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 2), (18, 5), (9, 2), (15, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 2), (18, 5), (9, 2), (15, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7611)$.", + "Output Answer": [ + "$4872$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7611))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67231 \\pmod{95}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "print(67231 % 95)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $17723$.", + "Output Answer": [ + "$37^1\\cdot 479^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(17723))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87456 \\pmod{81}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(87456 % 81)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41377)$.", + "Output Answer": [ + "$33792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41377))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $31159$.", + "Output Answer": [ + "$\\{3,6,7,13,15,24,28,31,37,48\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(31159):\n if len(roots) == 10: break\n if gcd(a, 31159) == 1 and is_primitive_root(a, 31159):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{283,-901,140\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 283, -901, 140\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $202^454 \\pmod{1111}$.", + "Output Answer": [ + "$707$" + ], + "Output Program": [ + "print(pow(202, 454, 1111))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2273^836 \\pmod{2731}$.", + "Output Answer": [ + "$187$" + ], + "Output Program": [ + "print(pow(2273, 836, 2731))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $57^m \\equiv 1 \\pmod{59}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(57, 59))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{870,619,712\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 870, 619, 712\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{841}{4568}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{84173777}-841}{9136}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(841/4568)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47392 \\pmod{56}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(47392 % 56)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-60610$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-60610 % -38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{2}$\n$x \\equiv 10 \\pmod{16}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 2), (10, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 2), (10, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20906)$.", + "Output Answer": [ + "$10452$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20906))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{19}$\n$x \\equiv 8 \\pmod{18}$", + "Output Answer": [ + "$170$" + ], + "Output Program": [ + "constraints = (18, 19), (8, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 19), (8, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 19), (8, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-225,25,7\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -225, 25, 7\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n463", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(463))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48823)$.", + "Output Answer": [ + "$48822$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48823))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{16}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "constraints = (1, 16), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 16), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 16), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35526)$.", + "Output Answer": [ + "$11400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35526))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{122}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 122))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{16}$\n$x \\equiv 5 \\pmod{9}$", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "constraints = (10, 16), (5, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 16), (5, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 16), (5, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $957^m \\equiv 1 \\pmod{970}$.", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(957, 970))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $83021$.", + "Output Answer": [ + "$61^1\\cdot 1361^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(83021))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n89627", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(89627))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 6 \\pmod{5}$\n$x \\equiv 18 \\pmod{18}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 3), (6, 5), (18, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 3), (6, 5), (18, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12257)$.", + "Output Answer": [ + "$9792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12257))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $6180$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6180 % -15 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3069}{4780}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{100812361}-3069}{9560}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3069/4780)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{337,-796,-390\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 337, -796, -390\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $80x \\equiv 1 \\pmod{193}$.", + "Output Answer": [ + "$152$" + ], + "Output Program": [ + "print(pow(80, -1, 193))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43414)$.", + "Output Answer": [ + "$18564$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43414))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(25843)$.", + "Output Answer": [ + "$25200$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(25843))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-201,-529,-628\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -201, -529, -628\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{6}$\n$x \\equiv 17 \\pmod{3}$\n$x \\equiv 17 \\pmod{3}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 6), (17, 3), (17, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 6), (17, 3), (17, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6343}{23268}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2205832945}-6343}{46536}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6343/23268)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n92705", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(92705))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n73561", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(73561))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61124 \\pmod{81}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "print(61124 % 81)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{18}$\n$x \\equiv 12 \\pmod{5}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (7, 18), (12, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 18), (12, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 18), (12, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1132}{741}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{741} \\left(\\sqrt{869437}-566\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1132/741)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68595 \\pmod{64}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(68595 % 64)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $713^1277 \\pmod{1476}$.", + "Output Answer": [ + "$1445$" + ], + "Output Program": [ + "print(pow(713, 1277, 1476))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21205)$.", + "Output Answer": [ + "$16960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21205))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 78170 \\pmod{38}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(78170 % 38)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1791$ to base $18$.", + "Output Answer": [ + "$599_{18}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 18\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1791\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-696,-395,185\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -696, -395, 185\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16804)$.", + "Output Answer": [ + "$8400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16804))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1657^1742 \\pmod{2765}$.", + "Output Answer": [ + "$2314$" + ], + "Output Program": [ + "print(pow(1657, 1742, 2765))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{929}{12308}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{606810497}-929}{24616}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(929/12308)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1325x \\equiv 1 \\pmod{2287}$.", + "Output Answer": [ + "$2161$" + ], + "Output Program": [ + "print(pow(1325, -1, 2287))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n42043", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(42043))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 13 \\pmod{20}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 11), (13, 19), (13, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 11), (13, 19), (13, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 11), (13, 19), (13, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22958)$.", + "Output Answer": [ + "$10584$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22958))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48474 \\pmod{62}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(48474 % 62)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1757^2014 \\pmod{2956}$.", + "Output Answer": [ + "$2541$" + ], + "Output Program": [ + "print(pow(1757, 2014, 2956))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{15}$\n$x \\equiv 17 \\pmod{7}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "constraints = (9, 15), (17, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 15), (17, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 15), (17, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $166^m \\equiv 1 \\pmod{295}$.", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(166, 295))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56066 \\pmod{18}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(56066 % 18)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10974}{10951}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{150031570}-5487}{10951}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10974/10951)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n467", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(467))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60432 \\pmod{64}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(60432 % 64)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-455,-583\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -455, -583\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-650,-416,367\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -650, -416, 367\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{548}{365}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{365} \\left(\\sqrt{208301}-274\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(548/365)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53419$.", + "Output Answer": [ + "$\\{2,3,7,10,11,12,13,17,18,28\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53419):\n if len(roots) == 10: break\n if gcd(a, 53419) == 1 and is_primitive_root(a, 53419):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3030$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3030 % 15 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5737}{1389}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{40630453}-5737}{2778}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5737/1389)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $10110011001_2$ to base 10.", + "Output Answer": [ + "$1433$" + ], + "Output Program": [ + "n = '10110011001'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{18120}{2339}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{87554521}-9060}{2339}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18120/2339)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{858,25\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 858, 25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89384 \\pmod{27}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(89384 % 27)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94508 \\pmod{22}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(94508 % 22)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{418,50\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 418, 50\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{56}$.", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "print(pow(37, -1, 56))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $303^m \\equiv 1 \\pmod{322}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(303, 322))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-542,437\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -542, 437\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{5}$\n$x \\equiv 14 \\pmod{14}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 5), (14, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 5), (14, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 5), (14, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $217x \\equiv 1 \\pmod{235}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(217, -1, 235))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85705 \\pmod{48}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(85705 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $4224$ is divisible by $11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(4224 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $239x \\equiv 1 \\pmod{435}$.", + "Output Answer": [ + "$344$" + ], + "Output Program": [ + "print(pow(239, -1, 435))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n73573", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(73573))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $629^489 \\pmod{1118}$.", + "Output Answer": [ + "$395$" + ], + "Output Program": [ + "print(pow(629, 489, 1118))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-18,-70,1\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -18, -70, 1\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-248,556\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = -248, 556\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $281^m \\equiv 1 \\pmod{365}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(281, 365))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $313x \\equiv 1 \\pmod{1305}$.", + "Output Answer": [ + "$517$" + ], + "Output Program": [ + "print(pow(313, -1, 1305))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.97$ to base $29$.", + "Output Answer": [ + "$\\text{0.s3ma}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.97\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11800 \\pmod{59}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(11800 % 59)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20804 \\pmod{61}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(20804 % 61)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $745^1328 \\pmod{1805}$.", + "Output Answer": [ + "$530$" + ], + "Output Program": [ + "print(pow(745, 1328, 1805))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{721,628,435\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 721, 628, 435\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-982,-10,7\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -982, -10, 7\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{6}$\n$x \\equiv 20 \\pmod{17}$\n$x \\equiv 2 \\pmod{12}$", + "Output Answer": [ + "$122$" + ], + "Output Program": [ + "constraints = (8, 6), (20, 17), (2, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 6), (20, 17), (2, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $939x \\equiv 1 \\pmod{1112}$.", + "Output Answer": [ + "$1067$" + ], + "Output Program": [ + "print(pow(939, -1, 1112))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{10}$\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 8 \\pmod{11}$", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 10), (1, 17), (8, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (2, 10), (1, 17), (8, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 10), (1, 17), (8, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{167}{660}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1770289}-167}{1320}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(167/660)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{607,832\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 607, 832\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79610 \\pmod{28}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(79610 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7208)$.", + "Output Answer": [ + "$3328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7208))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21306)$.", + "Output Answer": [ + "$6864$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21306))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $111^m \\equiv 1 \\pmod{986}$.", + "Output Answer": [ + "$56$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(111, 986))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{229,47,87\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 229, 47, 87\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $169$ to base $34$.", + "Output Answer": [ + "$\\text{4x}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 169\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1029^2238 \\pmod{2568}$.", + "Output Answer": [ + "$2025$" + ], + "Output Program": [ + "print(pow(1029, 2238, 2568))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{270,-833\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 270, -833\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{18}$\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 8 \\pmod{8}$", + "Output Answer": [ + "$200$" + ], + "Output Program": [ + "constraints = (2, 18), (5, 15), (8, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 18), (5, 15), (8, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{196,3,332\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 196, 3, 332\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12748)$.", + "Output Answer": [ + "$6372$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12748))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $648x \\equiv 1 \\pmod{871}$.", + "Output Answer": [ + "$539$" + ], + "Output Program": [ + "print(pow(648, -1, 871))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1140$ is divisible by $30$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1140 % 30 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $39x \\equiv 1 \\pmod{106}$.", + "Output Answer": [ + "$87$" + ], + "Output Program": [ + "print(pow(39, -1, 106))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3853}{8185}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{282822509}-3853}{16370}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3853/8185)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $37426$.", + "Output Answer": [ + "$2^1\\cdot 18713^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37426))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12923}{18276}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1503052633}-12923}{36552}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12923/18276)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3944)$.", + "Output Answer": [ + "$1792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3944))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-600,-781\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -600, -781\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-463,-960\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -463, -960\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{43,375\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 43, 375\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22346)$.", + "Output Answer": [ + "$11172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22346))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{156,-786\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 156, -786\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $259x \\equiv 1 \\pmod{363}$.", + "Output Answer": [ + "$178$" + ], + "Output Program": [ + "print(pow(259, -1, 363))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7312}{26107}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{694941785}-3656}{26107}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7312/26107)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{702}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 702))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5122}{1975}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10459346}-2561}{1975}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5122/1975)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{79}{174}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{348} \\left(\\sqrt{127345}-79\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(79/174)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70090 \\pmod{96}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(70090 % 96)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1520^1756 \\pmod{1635}$.", + "Output Answer": [ + "$1615$" + ], + "Output Program": [ + "print(pow(1520, 1756, 1635))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6705}{1846}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{58587889}-6705}{3692}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6705/1846)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{0,-1,2,-4\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = 0, -1, 2, -4\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{5}$\n$x \\equiv 1 \\pmod{4}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 5), (1, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 5), (1, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (7, 5), (1, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-94,25\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -94, 25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{6}$\n$x \\equiv 10 \\pmod{8}$\n$x \\equiv 6 \\pmod{12}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 6), (10, 8), (6, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (6, 6), (10, 8), (6, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $34052$.", + "Output Answer": [ + "$2^2\\cdot 8513^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(34052))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31242)$.", + "Output Answer": [ + "$10080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31242))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $507^831 \\pmod{1117}$.", + "Output Answer": [ + "$541$" + ], + "Output Program": [ + "print(pow(507, 831, 1117))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $13$ to base $6$.", + "Output Answer": [ + "$21_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 13\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-263,-194\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -263, -194\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8705}{12174}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{668602129}-8705}{24348}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8705/12174)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99831 \\pmod{35}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(99831 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2658}{2615}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{50914}-1329}{2615}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2658/2615)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24489 \\pmod{87}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(24489 % 87)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93009 \\pmod{45}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(93009 % 45)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{109,-165,364\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 109, -165, 364\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $27756$ is divisible by $27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(27756 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 0 \\pmod{13}$\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 11 \\pmod{18}$", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "constraints = (5, 4), (0, 13), (5, 2), (11, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 4), (0, 13), (5, 2), (11, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $29^m \\equiv 1 \\pmod{644}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(29, 644))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{2}$\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 12 \\pmod{16}$", + "Output Answer": [ + "$236$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 2), (8, 19), (12, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 2), (8, 19), (12, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{127,-290,454\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 127, -290, 454\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{977,146\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 977, 146\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9287}{6896}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{276467633}-9287}{13792}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9287/6896)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{12}$\n$x \\equiv 20 \\pmod{20}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 12), (20, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 12), (20, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29206)$.", + "Output Answer": [ + "$13728$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29206))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $7543$ is divisible by $19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7543 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $883x \\equiv 1 \\pmod{2442}$.", + "Output Answer": [ + "$1687$" + ], + "Output Program": [ + "print(pow(883, -1, 2442))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54498 \\pmod{80}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "print(54498 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n40495", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(40495))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{577,3,-43\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 577, 3, -43\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $587^m \\equiv 1 \\pmod{833}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(587, 833))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1409x \\equiv 1 \\pmod{1747}$.", + "Output Answer": [ + "$1318$" + ], + "Output Program": [ + "print(pow(1409, -1, 1747))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3166}{197}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{197} \\left(\\sqrt{2544698}-1583\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3166/197)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{4,-5,1,-1\\}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nvalues = 4, -5, 1, -1\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n51869", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51869))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-33592$ is divisible by $-34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-33592 % -34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1111101101_2$ to base 10.", + "Output Answer": [ + "$1005$" + ], + "Output Program": [ + "n = '1111101101'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(42946)$.", + "Output Answer": [ + "$21168$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(42946))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-559,-291\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -559, -291\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2437}{3638}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{58879145}-2437}{7276}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2437/3638)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $521x \\equiv 1 \\pmod{2364}$.", + "Output Answer": [ + "$1697$" + ], + "Output Program": [ + "print(pow(521, -1, 2364))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{471,-339,358\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 471, -339, 358\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1645x \\equiv 1 \\pmod{1952}$.", + "Output Answer": [ + "$1189$" + ], + "Output Program": [ + "print(pow(1645, -1, 1952))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $440^115 \\pmod{2314}$.", + "Output Answer": [ + "$366$" + ], + "Output Program": [ + "print(pow(440, 115, 2314))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 15541 \\pmod{39}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(15541 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $568^m \\equiv 1 \\pmod{937}$.", + "Output Answer": [ + "$936$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(568, 937))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.433$ to base $4$.", + "Output Answer": [ + "$0.1232312101_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.433\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $806^2317 \\pmod{2435}$.", + "Output Answer": [ + "$901$" + ], + "Output Program": [ + "print(pow(806, 2317, 2435))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n147", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(147))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.049$ to base $32$.", + "Output Answer": [ + "$\\text{0.1i5k}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.049\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10687}{7476}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{337774273}-10687}{14952}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10687/7476)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64010 \\pmod{93}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(64010 % 93)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1596$ to base $15$.", + "Output Answer": [ + "$716_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1596\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-918$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-918 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2294^2306 \\pmod{2762}$.", + "Output Answer": [ + "$1986$" + ], + "Output Program": [ + "print(pow(2294, 2306, 2762))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7382}{217}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{217} \\left(\\sqrt{13670570}-3691\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7382/217)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $63629$.", + "Output Answer": [ + "$63629^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(63629))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58011 \\pmod{52}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(58011 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{9}$\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 12 \\pmod{5}$", + "Output Answer": [ + "$697$" + ], + "Output Program": [ + "constraints = (13, 9), (13, 19), (12, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 9), (13, 19), (12, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 9), (13, 19), (12, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{10}$\n$x \\equiv 3 \\pmod{13}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 20 \\pmod{17}$", + "Output Answer": [ + "$21219$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 10), (3, 13), (11, 11), (20, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (9, 10), (3, 13), (11, 11), (20, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 10), (3, 13), (11, 11), (20, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{2}$\n$x \\equiv 9 \\pmod{20}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (11, 2), (9, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 2), (9, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7114)$.", + "Output Answer": [ + "$3556$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7114))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $505^m \\equiv 1 \\pmod{746}$.", + "Output Answer": [ + "$372$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(505, 746))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $107^m \\equiv 1 \\pmod{461}$.", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(107, 461))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1165$ to base $11$.", + "Output Answer": [ + "$\\text{96a}_{11}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 11\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1165\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $695x \\equiv 1 \\pmod{1411}$.", + "Output Answer": [ + "$739$" + ], + "Output Program": [ + "print(pow(695, -1, 1411))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{604,401,159\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 604, 401, 159\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-82908$ is divisible by $-47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-82908 % -47 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44879)$.", + "Output Answer": [ + "$44878$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44879))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $97^m \\equiv 1 \\pmod{622}$.", + "Output Answer": [ + "$310$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(97, 622))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{12}$\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 7 \\pmod{17}$", + "Output Answer": [ + "$806$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 12), (16, 10), (7, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 12), (16, 10), (7, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{967,129\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 967, 129\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{85,-901,-584\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 85, -901, -584\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n60345", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(60345))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $13051$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(13051 % -31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n71635", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(71635))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8117}{12426}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{683507593}-8117}{24852}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8117/12426)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{79,230,181\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 79, 230, 181\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2877}{2006}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{24373273}-2877}{4012}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2877/2006)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1343^1331 \\pmod{2619}$.", + "Output Answer": [ + "$914$" + ], + "Output Program": [ + "print(pow(1343, 1331, 2619))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $14024_5$ to base 10.", + "Output Answer": [ + "$1139$" + ], + "Output Program": [ + "n = '14024'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4289 \\pmod{54}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(4289 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27403 \\pmod{71}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(27403 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n51511", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51511))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{824,-790,-462\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 824, -790, -462\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $495$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(495 % 22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1649$ to base $19$.", + "Output Answer": [ + "$\\text{4af}_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1649\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19931}{15673}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1379816477}-19931}{31346}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19931/15673)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57148 \\pmod{96}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(57148 % 96)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $942^173 \\pmod{2071}$.", + "Output Answer": [ + "$1622$" + ], + "Output Program": [ + "print(pow(942, 173, 2071))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $151^m \\equiv 1 \\pmod{392}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(151, 392))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17433 \\pmod{80}$.", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "print(17433 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1050^1909 \\pmod{2320}$.", + "Output Answer": [ + "$1280$" + ], + "Output Program": [ + "print(pow(1050, 1909, 2320))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $154^m \\equiv 1 \\pmod{331}$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(154, 331))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $268^896 \\pmod{865}$.", + "Output Answer": [ + "$636$" + ], + "Output Program": [ + "print(pow(268, 896, 865))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{20021}{2323}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{422425757}-20021}{4646}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20021/2323)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67152 \\pmod{24}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(67152 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7594)$.", + "Output Answer": [ + "$3796$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7594))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-560$ is divisible by $5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-560 % 5 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n93609", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(93609))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n7221", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7221))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2308^2098 \\pmod{2472}$.", + "Output Answer": [ + "$1456$" + ], + "Output Program": [ + "print(pow(2308, 2098, 2472))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6536 \\pmod{38}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(6536 % 38)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $133^m \\equiv 1 \\pmod{986}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(133, 986))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41194)$.", + "Output Answer": [ + "$20076$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41194))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40624)$.", + "Output Answer": [ + "$20304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40624))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2183 \\pmod{88}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(2183 % 88)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31266 \\pmod{80}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "print(31266 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27741)$.", + "Output Answer": [ + "$15840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27741))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n75853", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(75853))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{7}$\n$x \\equiv 2 \\pmod{11}$\n$x \\equiv 5 \\pmod{4}$", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 7), (2, 11), (5, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 7), (2, 11), (5, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 7), (2, 11), (5, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19487 \\pmod{31}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(19487 % 31)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{515,289,56\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 515, 289, 56\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5551}{3642}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{83870257}-5551}{7284}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5551/3642)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53122$.", + "Output Answer": [ + "$\\{3,7,11,13,15,17,19,23,27,29\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53122):\n if len(roots) == 10: break\n if gcd(a, 53122) == 1 and is_primitive_root(a, 53122):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $4x \\equiv 1 \\pmod{195}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(pow(4, -1, 195))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n51789", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51789))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $37903$.", + "Output Answer": [ + "$29^1\\cdot 1307^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29887)$.", + "Output Answer": [ + "$23760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29887))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{924}{3991}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{645661}-462}{3991}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(924/3991)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{16}$\n$x \\equiv 14 \\pmod{10}$\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 0 \\pmod{12}$", + "Output Answer": [ + "$3564$" + ], + "Output Program": [ + "constraints = (12, 16), (14, 10), (11, 17), (0, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 16), (14, 10), (11, 17), (0, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19898)$.", + "Output Answer": [ + "$9948$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19898))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 18 \\pmod{17}$", + "Output Answer": [ + "$103$" + ], + "Output Program": [ + "constraints = (15, 11), (18, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 11), (18, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 11), (18, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{219}{1633}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10714717}-219}{3266}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(219/1633)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.36$ to base $28$.", + "Output Answer": [ + "$\\text{0.a26k}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.36\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $159x \\equiv 1 \\pmod{164}$.", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "print(pow(159, -1, 164))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $139^m \\equiv 1 \\pmod{534}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(139, 534))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9970 \\pmod{47}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(9970 % 47)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $57719$.", + "Output Answer": [ + "$\\{7,14,19,21,23,28,31,35,38,42\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(57719):\n if len(roots) == 10: break\n if gcd(a, 57719) == 1 and is_primitive_root(a, 57719):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.54513_9$ to base 10.", + "Output Answer": [ + "$0.612$" + ], + "Output Program": [ + "n = '0.54513'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $311^m \\equiv 1 \\pmod{714}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(311, 714))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1140^810 \\pmod{2616}$.", + "Output Answer": [ + "$1416$" + ], + "Output Program": [ + "print(pow(1140, 810, 2616))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(575)$.", + "Output Answer": [ + "$440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(575))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n43775", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(43775))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $41378$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(41378 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5491$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5491 % -17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43545)$.", + "Output Answer": [ + "$23216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43545))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $340^471 \\pmod{2453}$.", + "Output Answer": [ + "$219$" + ], + "Output Program": [ + "print(pow(340, 471, 2453))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21052 \\pmod{32}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(21052 % 32)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $410^956 \\pmod{1270}$.", + "Output Answer": [ + "$920$" + ], + "Output Program": [ + "print(pow(410, 956, 1270))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9117}{5810}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{218144089}-9117}{11620}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9117/5810)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{4}$\n$x \\equiv 8 \\pmod{9}$\n$x \\equiv 13 \\pmod{11}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 4), (8, 9), (13, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 4), (8, 9), (13, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 4), (8, 9), (13, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2535}{374}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{748} \\left(\\sqrt{6985729}-2535\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2535/374)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3677}{580}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{14865929}-3677}{1160}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3677/580)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2111)$.", + "Output Answer": [ + "$2110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2111))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12424 \\pmod{24}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(12424 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $252x \\equiv 1 \\pmod{2027}$.", + "Output Answer": [ + "$1842$" + ], + "Output Program": [ + "print(pow(252, -1, 2027))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2672)$.", + "Output Answer": [ + "$1328$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2672))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n33331", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(33331))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{22537}{27540}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3541722769}-22537}{55080}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22537/27540)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{19}$\n$x \\equiv 17 \\pmod{19}$\n$x \\equiv 5 \\pmod{9}$\n$x \\equiv 8 \\pmod{3}$", + "Output Answer": [ + "$131$" + ], + "Output Program": [ + "constraints = (17, 19), (17, 19), (5, 9), (8, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 19), (17, 19), (5, 9), (8, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1577^2393 \\pmod{2632}$.", + "Output Answer": [ + "$1201$" + ], + "Output Program": [ + "print(pow(1577, 2393, 2632))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96226 \\pmod{3}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(96226 % 3)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 20 \\pmod{16}$", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "constraints = (13, 11), (20, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (20, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (13, 11), (20, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 99869 \\pmod{35}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(99869 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n32121", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(32121))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1392$ to base $33$.", + "Output Answer": [ + "$196_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1392\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3100$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3100 % -10 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2976$ to base $7$.", + "Output Answer": [ + "$11451_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2976\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-131,-165\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -131, -165\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50926 \\pmod{94}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "print(50926 % 94)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $68278$.", + "Output Answer": [ + "$2^1\\cdot 7^1\\cdot 4877^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(68278))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $154^m \\equiv 1 \\pmod{499}$.", + "Output Answer": [ + "$166$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(154, 499))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-452,19\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -452, 19\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19144)$.", + "Output Answer": [ + "$9568$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19144))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $544x \\equiv 1 \\pmod{585}$.", + "Output Answer": [ + "$214$" + ], + "Output Program": [ + "print(pow(544, -1, 585))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{26429}{24137}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3028871117}-26429}{48274}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26429/24137)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8941}{26228}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2831573417}-8941}{52456}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8941/26228)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 15 \\pmod{9}$", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 11), (15, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 11), (15, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 11), (15, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11100 \\pmod{12}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(11100 % 12)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{8}$\n$x \\equiv 4 \\pmod{13}$", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 8), (4, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 8), (4, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (5, 8), (4, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-592$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-592 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.586$ to base $34$.", + "Output Answer": [ + "$\\text{0.jve5}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.586\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37848 \\pmod{80}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(37848 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{787,725,968\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 787, 725, 968\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-269,-700\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -269, -700\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.83$ to base $3$.", + "Output Answer": [ + "$0.21110200122_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.83\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{8}$\n$x \\equiv 10 \\pmod{11}$\n$x \\equiv 10 \\pmod{10}$\n$x \\equiv 20 \\pmod{2}$", + "Output Answer": [ + "$230$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 8), (10, 11), (10, 10), (20, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 8), (10, 11), (10, 10), (20, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20990)$.", + "Output Answer": [ + "$8392$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20990))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55244 \\pmod{65}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(55244 % 65)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $838x \\equiv 1 \\pmod{863}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "print(pow(838, -1, 863))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1260$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1260 % 6 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{222,-995,91\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 222, -995, 91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $5701$.", + "Output Answer": [ + "$\\{2,6,10,17,21,22,24,28,29,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(5701):\n if len(roots) == 10: break\n if gcd(a, 5701) == 1 and is_primitive_root(a, 5701):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $232^m \\equiv 1 \\pmod{239}$.", + "Output Answer": [ + "$119$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(232, 239))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21389 \\pmod{86}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(21389 % 86)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n99279", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(99279))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2237$ to base $22$.", + "Output Answer": [ + "$\\text{4df}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2237\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{4,-2,1,-3\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = 4, -2, 1, -3\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{167}{6138}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{150728065}-167}{12276}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(167/6138)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $12754$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(12754 % 28 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{20}$\n$x \\equiv 13 \\pmod{9}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 20), (13, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 20), (13, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 20), (13, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9733}{16231}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1148512733}-9733}{32462}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9733/16231)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5824$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(5824 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $47^m \\equiv 1 \\pmod{236}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(47, 236))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $65x \\equiv 1 \\pmod{464}$.", + "Output Answer": [ + "$257$" + ], + "Output Program": [ + "print(pow(65, -1, 464))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{508,797\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 508, 797\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{209,-199,692\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 209, -199, 692\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $30914$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(30914 % 29 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1166^1867 \\pmod{1691}$.", + "Output Answer": [ + "$691$" + ], + "Output Program": [ + "print(pow(1166, 1867, 1691))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{18}$\n$x \\equiv 11 \\pmod{11}$", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "import math\n\nconstraints = (2, 18), (11, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 18), (11, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 18), (11, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $729x \\equiv 1 \\pmod{2488}$.", + "Output Answer": [ + "$529$" + ], + "Output Program": [ + "print(pow(729, -1, 2488))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21740)$.", + "Output Answer": [ + "$8688$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21740))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14628)$.", + "Output Answer": [ + "$4576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14628))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8759}{1553}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{86367317}-8759}{3106}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8759/1553)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 28017 \\pmod{33}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(28017 % 33)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $300^m \\equiv 1 \\pmod{383}$.", + "Output Answer": [ + "$191$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(300, 383))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-535,552,-3\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -535, 552, -3\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{24810}{19157}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{520874674}-12405}{19157}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24810/19157)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $783x \\equiv 1 \\pmod{796}$.", + "Output Answer": [ + "$551$" + ], + "Output Program": [ + "print(pow(783, -1, 796))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1049x \\equiv 1 \\pmod{1642}$.", + "Output Answer": [ + "$803$" + ], + "Output Program": [ + "print(pow(1049, -1, 1642))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n46097", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(46097))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $49x \\equiv 1 \\pmod{340}$.", + "Output Answer": [ + "$229$" + ], + "Output Program": [ + "print(pow(49, -1, 340))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{602,906\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 602, 906\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{355}{1512}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9270601}-355}{3024}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(355/1512)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1821x \\equiv 1 \\pmod{2342}$.", + "Output Answer": [ + "$935$" + ], + "Output Program": [ + "print(pow(1821, -1, 2342))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61336 \\pmod{17}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(61336 % 17)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 20203 \\pmod{89}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(20203 % 89)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2404^1841 \\pmod{2703}$.", + "Output Answer": [ + "$1027$" + ], + "Output Program": [ + "print(pow(2404, 1841, 2703))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1364^1463 \\pmod{2733}$.", + "Output Answer": [ + "$2474$" + ], + "Output Program": [ + "print(pow(1364, 1463, 2733))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{992,413\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 992, 413\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $62477$.", + "Output Answer": [ + "$\\{2,3,5,8,11,12,14,18,20,21\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(62477):\n if len(roots) == 10: break\n if gcd(a, 62477) == 1 and is_primitive_root(a, 62477):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-101097$ is divisible by $47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-101097 % 47 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25283 \\pmod{54}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(25283 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4861}{3334}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{68091545}-4861}{6668}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4861/3334)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17931}{1552}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{331155577}-17931}{3104}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17931/1552)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n69017", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(69017))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $133^m \\equiv 1 \\pmod{353}$.", + "Output Answer": [ + "$352$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(133, 353))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{876,114\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 876, 114\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{176}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 176))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(259)$.", + "Output Answer": [ + "$216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(259))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3825}{947}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{18217861}-3825}{1894}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3825/947)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{17}$\n$x \\equiv 5 \\pmod{4}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 17), (5, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 17), (5, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 17), (5, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1985x \\equiv 1 \\pmod{2228}$.", + "Output Answer": [ + "$761$" + ], + "Output Program": [ + "print(pow(1985, -1, 2228))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40199 \\pmod{81}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(40199 % 81)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $769^m \\equiv 1 \\pmod{911}$.", + "Output Answer": [ + "$182$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(769, 911))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1583^229 \\pmod{2100}$.", + "Output Answer": [ + "$2003$" + ], + "Output Program": [ + "print(pow(1583, 229, 2100))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1231x \\equiv 1 \\pmod{2106}$.", + "Output Answer": [ + "$1615$" + ], + "Output Program": [ + "print(pow(1231, -1, 2106))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $68^m \\equiv 1 \\pmod{91}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(68, 91))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $48x \\equiv 1 \\pmod{173}$.", + "Output Answer": [ + "$155$" + ], + "Output Program": [ + "print(pow(48, -1, 173))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 20 \\pmod{13}$", + "Output Answer": [ + "$124$" + ], + "Output Program": [ + "constraints = (10, 2), (14, 11), (20, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 2), (14, 11), (20, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 2), (14, 11), (20, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n102191", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(102191))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{149,-180,-274\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 149, -180, -274\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $709x \\equiv 1 \\pmod{1150}$.", + "Output Answer": [ + "$339$" + ], + "Output Program": [ + "print(pow(709, -1, 1150))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-761,918\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -761, 918\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $329x \\equiv 1 \\pmod{922}$.", + "Output Answer": [ + "$227$" + ], + "Output Program": [ + "print(pow(329, -1, 922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $539x \\equiv 1 \\pmod{1292}$.", + "Output Answer": [ + "$163$" + ], + "Output Program": [ + "print(pow(539, -1, 1292))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $144_{29}$ to base 10.", + "Output Answer": [ + "$961$" + ], + "Output Program": [ + "n = '144'.strip('.')\nbase = 29\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1010^2150 \\pmod{1179}$.", + "Output Answer": [ + "$211$" + ], + "Output Program": [ + "print(pow(1010, 2150, 1179))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{928}{1145}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1526321}-464}{1145}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(928/1145)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25870 \\pmod{3}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(25870 % 3)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $55^m \\equiv 1 \\pmod{402}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(55, 402))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22069 \\pmod{18}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(22069 % 18)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1770^1446 \\pmod{2285}$.", + "Output Answer": [ + "$740$" + ], + "Output Program": [ + "print(pow(1770, 1446, 2285))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2181^1114 \\pmod{2393}$.", + "Output Answer": [ + "$339$" + ], + "Output Program": [ + "print(pow(2181, 1114, 2393))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $17326$.", + "Output Answer": [ + "$\\{5,7,13,15,17,21,29,31,37,39\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(17326):\n if len(roots) == 10: break\n if gcd(a, 17326) == 1 and is_primitive_root(a, 17326):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $284^2040 \\pmod{1197}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(pow(284, 2040, 1197))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19891 \\pmod{73}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(19891 % 73)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10357}{9028}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{433286585}-10357}{18056}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10357/9028)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2428^1269 \\pmod{2487}$.", + "Output Answer": [ + "$961$" + ], + "Output Program": [ + "print(pow(2428, 1269, 2487))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{311}{1566}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{9906145}-311}{3132}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(311/1566)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n42675", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(42675))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $502^m \\equiv 1 \\pmod{543}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(502, 543))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $33x \\equiv 1 \\pmod{106}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(pow(33, -1, 106))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $922x \\equiv 1 \\pmod{1975}$.", + "Output Answer": [ + "$1583$" + ], + "Output Program": [ + "print(pow(922, -1, 1975))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 30212 \\pmod{44}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(30212 % 44)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $54673$.", + "Output Answer": [ + "$\\{5,13,15,19,20,21,26,30,38,40\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(54673):\n if len(roots) == 10: break\n if gcd(a, 54673) == 1 and is_primitive_root(a, 54673):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n11501", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(11501))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47334 \\pmod{84}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(47334 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-472,-838\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -472, -838\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n78795", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(78795))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19641}{10591}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{834446005}-19641}{21182}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19641/10591)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52315 \\pmod{53}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "print(52315 % 53)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $586x \\equiv 1 \\pmod{2087}$.", + "Output Answer": [ + "$1884$" + ], + "Output Program": [ + "print(pow(586, -1, 2087))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-744,-591\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -744, -591\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10877)$.", + "Output Answer": [ + "$10656$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10877))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76136 \\pmod{16}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(76136 % 16)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{830,786\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 830, 786\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $5^m \\equiv 1 \\pmod{807}$.", + "Output Answer": [ + "$134$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(5, 807))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1842$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1842 % -45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7677)$.", + "Output Answer": [ + "$5112$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7677))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n52311", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(52311))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{385}{751}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2404229}-385}{1502}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(385/751)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $37760$ is divisible by $-32$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(37760 % -32 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2317$ to base $16$.", + "Output Answer": [ + "$\\text{90d}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2317\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-742,-127,-518\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -742, -127, -518\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6897}{2149}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{228517}-6897}{4298}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6897/2149)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-669,855,187\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -669, 855, 187\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 19 \\pmod{15}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "constraints = (14, 7), (19, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 7), (19, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 7), (19, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1891$ is divisible by $46$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1891 % 46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69140 \\pmod{49}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(69140 % 49)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18390)$.", + "Output Answer": [ + "$4896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18390))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-978,139,513\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -978, 139, 513\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-73752$ is divisible by $42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-73752 % 42 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{296}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 296))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $11684$ is divisible by $23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(11684 % 23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $4x \\equiv 1 \\pmod{17}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(4, -1, 17))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-862,245\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -862, 245\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $943x \\equiv 1 \\pmod{1834}$.", + "Output Answer": [ + "$1305$" + ], + "Output Program": [ + "print(pow(943, -1, 1834))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 96651 \\pmod{42}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(96651 % 42)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n50515", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50515))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $416x \\equiv 1 \\pmod{1489}$.", + "Output Answer": [ + "$970$" + ], + "Output Program": [ + "print(pow(416, -1, 1489))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36893 \\pmod{97}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(36893 % 97)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $6435$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(6435 % -15 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1110^1113 \\pmod{1305}$.", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "print(pow(1110, 1113, 1305))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $91^m \\equiv 1 \\pmod{177}$.", + "Output Answer": [ + "$58$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(91, 177))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6608)$.", + "Output Answer": [ + "$2784$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6608))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $3000$ is divisible by $12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(3000 % 12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $95^m \\equiv 1 \\pmod{542}$.", + "Output Answer": [ + "$270$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(95, 542))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $553x \\equiv 1 \\pmod{1618}$.", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "print(pow(553, -1, 1618))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $826^m \\equiv 1 \\pmod{963}$.", + "Output Answer": [ + "$318$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(826, 963))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $21^m \\equiv 1 \\pmod{662}$.", + "Output Answer": [ + "$165$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(21, 662))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3667)$.", + "Output Answer": [ + "$3456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3667))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $852x \\equiv 1 \\pmod{1577}$.", + "Output Answer": [ + "$1279$" + ], + "Output Program": [ + "print(pow(852, -1, 1577))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $107x \\equiv 1 \\pmod{740}$.", + "Output Answer": [ + "$83$" + ], + "Output Program": [ + "print(pow(107, -1, 740))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n24821", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24821))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 14 \\pmod{4}$\n$x \\equiv 4 \\pmod{17}$", + "Output Answer": [ + "$378$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 7), (14, 4), (4, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 7), (14, 4), (4, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 7), (14, 4), (4, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $120^m \\equiv 1 \\pmod{727}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(120, 727))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $258^m \\equiv 1 \\pmod{299}$.", + "Output Answer": [ + "$132$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(258, 299))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n11841", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(11841))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $50055$.", + "Output Answer": [ + "$3^1\\cdot 5^1\\cdot 47^1\\cdot 71^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(50055))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1582$ to base $16$.", + "Output Answer": [ + "$\\text{62e}_{16}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 16\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1582\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1711}{324}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{648} \\left(5 \\sqrt{133897}-1711\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1711/324)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37569 \\pmod{70}$.", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "print(37569 % 70)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $660^2177 \\pmod{2872}$.", + "Output Answer": [ + "$2112$" + ], + "Output Program": [ + "print(pow(660, 2177, 2872))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37507)$.", + "Output Answer": [ + "$37506$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37507))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $119x \\equiv 1 \\pmod{1154}$.", + "Output Answer": [ + "$417$" + ], + "Output Program": [ + "print(pow(119, -1, 1154))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $83100$.", + "Output Answer": [ + "$2^2\\cdot 3^1\\cdot 5^2\\cdot 277^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(83100))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{528,-867,-819\\}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "import math\n\nvalues = 528, -867, -819\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n37635", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(37635))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $35869$.", + "Output Answer": [ + "$\\{10,13,14,18,24,40,41,46,50,53\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(35869):\n if len(roots) == 10: break\n if gcd(a, 35869) == 1 and is_primitive_root(a, 35869):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{889}{2652}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{28922737}-889}{5304}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(889/2652)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15115}{94}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{188} \\left(\\sqrt{228498569}-15115\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15115/94)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{401,-91\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 401, -91\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $428^915 \\pmod{2874}$.", + "Output Answer": [ + "$1004$" + ], + "Output Program": [ + "print(pow(428, 915, 2874))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $286^m \\equiv 1 \\pmod{667}$.", + "Output Answer": [ + "$154$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(286, 667))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $251^m \\equiv 1 \\pmod{990}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(251, 990))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-833$ is divisible by $17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-833 % 17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17600}{7929}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{140309041}-8800}{7929}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17600/7929)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $99x \\equiv 1 \\pmod{614}$.", + "Output Answer": [ + "$583$" + ], + "Output Program": [ + "print(pow(99, -1, 614))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $415x \\equiv 1 \\pmod{624}$.", + "Output Answer": [ + "$415$" + ], + "Output Program": [ + "print(pow(415, -1, 624))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n72383", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(72383))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{6}$\n$x \\equiv 3 \\pmod{13}$\n$x \\equiv 5 \\pmod{5}$", + "Output Answer": [ + "$250$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 6), (3, 13), (5, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 6), (3, 13), (5, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 6), (3, 13), (5, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $44032$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(44032 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $221^m \\equiv 1 \\pmod{371}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(221, 371))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 71875 \\pmod{29}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(71875 % 29)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $119^2345 \\pmod{1820}$.", + "Output Answer": [ + "$539$" + ], + "Output Program": [ + "print(pow(119, 2345, 1820))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $339x \\equiv 1 \\pmod{2306}$.", + "Output Answer": [ + "$1721$" + ], + "Output Program": [ + "print(pow(339, -1, 2306))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.2753412_8$ to base 10.", + "Output Answer": [ + "$0.37$" + ], + "Output Program": [ + "n = '0.2753412'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3997)$.", + "Output Answer": [ + "$3420$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3997))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $149^m \\equiv 1 \\pmod{184}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(149, 184))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1398_{13}$ to base 10.", + "Output Answer": [ + "$2829$" + ], + "Output Program": [ + "n = '1398'.strip('.')\nbase = 13\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 4 \\pmod{3}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 5), (4, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 5), (4, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (13, 5), (4, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23763 \\pmod{72}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(23763 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $88^m \\equiv 1 \\pmod{457}$.", + "Output Answer": [ + "$152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(88, 457))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n36819", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(36819))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67339 \\pmod{93}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(67339 % 93)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24092)$.", + "Output Answer": [ + "$11376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24092))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $155^m \\equiv 1 \\pmod{212}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(155, 212))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $443^469 \\pmod{2408}$.", + "Output Answer": [ + "$1283$" + ], + "Output Program": [ + "print(pow(443, 469, 2408))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19647 \\pmod{84}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "print(19647 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $37046$.", + "Output Answer": [ + "$\\{3,5,7,13,29,33,45,55,61,75\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(37046):\n if len(roots) == 10: break\n if gcd(a, 37046) == 1 and is_primitive_root(a, 37046):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n53949", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(53949))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{17}$\n$x \\equiv 0 \\pmod{8}$\n$x \\equiv 12 \\pmod{19}$\n$x \\equiv 6 \\pmod{7}$", + "Output Answer": [ + "$12704$" + ], + "Output Program": [ + "constraints = (5, 17), (0, 8), (12, 19), (6, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (5, 17), (0, 8), (12, 19), (6, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 17), (0, 8), (12, 19), (6, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $7499$.", + "Output Answer": [ + "$7499^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(7499))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2717}{3126}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46469593}-2717}{6252}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2717/3126)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{14}$\n$x \\equiv 20 \\pmod{4}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "constraints = (20, 14), (20, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 14), (20, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{11714}{3243}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{44821498}-5857}{3243}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11714/3243)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1015^887 \\pmod{2422}$.", + "Output Answer": [ + "$497$" + ], + "Output Program": [ + "print(pow(1015, 887, 2422))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n1877", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1877))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $699^494 \\pmod{2001}$.", + "Output Answer": [ + "$1398$" + ], + "Output Program": [ + "print(pow(699, 494, 2001))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20718)$.", + "Output Answer": [ + "$6900$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20718))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{679}{568}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1751537}-679}{1136}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(679/568)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 10 \\pmod{19}$\n$x \\equiv 1 \\pmod{9}$\n$x \\equiv 1 \\pmod{13}$", + "Output Answer": [ + "$4798$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 10), (10, 19), (1, 9), (1, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 10), (10, 19), (1, 9), (1, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (18, 10), (10, 19), (1, 9), (1, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $38682$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(38682 % -42 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 6 \\pmod{3}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (6, 17), (6, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 17), (6, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (6, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $953x \\equiv 1 \\pmod{1268}$.", + "Output Answer": [ + "$793$" + ], + "Output Program": [ + "print(pow(953, -1, 1268))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $243$.", + "Output Answer": [ + "$\\{2,5,11,14,20,23,29,32,38,41\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(243):\n if len(roots) == 10: break\n if gcd(a, 243) == 1 and is_primitive_root(a, 243):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2354^762 \\pmod{2756}$.", + "Output Answer": [ + "$196$" + ], + "Output Program": [ + "print(pow(2354, 762, 2756))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1332$ to base $33$.", + "Output Answer": [ + "$\\text{17c}_{33}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 33\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1332\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75815 \\pmod{87}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(75815 % 87)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $37632$ is divisible by $32$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(37632 % 32 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{19}$\n$x \\equiv 3 \\pmod{18}$\n$x \\equiv 3 \\pmod{20}$\n$x \\equiv 7 \\pmod{14}$", + "Output Answer": [ + "$903$" + ], + "Output Program": [ + "constraints = (10, 19), (3, 18), (3, 20), (7, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 19), (3, 18), (3, 20), (7, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1040}{34789}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1210544921}-520}{34789}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1040/34789)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $676^m \\equiv 1 \\pmod{987}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(676, 987))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 6501 \\pmod{25}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(6501 % 25)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(8335)$.", + "Output Answer": [ + "$6664$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(8335))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34009)$.", + "Output Answer": [ + "$33460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34009))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1271x \\equiv 1 \\pmod{1680}$.", + "Output Answer": [ + "$1031$" + ], + "Output Program": [ + "print(pow(1271, -1, 1680))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.185166_9$ to base 10.", + "Output Answer": [ + "$0.217$" + ], + "Output Program": [ + "n = '0.185166'.strip('.')\nbase = 9\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1442^2361 \\pmod{2240}$.", + "Output Answer": [ + "$1792$" + ], + "Output Program": [ + "print(pow(1442, 2361, 2240))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 18 \\pmod{17}$", + "Output Answer": [ + "$120$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 8), (16, 4), (18, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 8), (16, 4), (18, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10634}{13843}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{219899138}-5317}{13843}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10634/13843)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{2}$\n$x \\equiv 7 \\pmod{7}$\n$x \\equiv 18 \\pmod{12}$\n$x \\equiv 5 \\pmod{11}$", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "constraints = (14, 2), (7, 7), (18, 12), (5, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 2), (7, 7), (18, 12), (5, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $631x \\equiv 1 \\pmod{1248}$.", + "Output Answer": [ + "$1159$" + ], + "Output Program": [ + "print(pow(631, -1, 1248))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1472$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1472 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{14}$\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 12 \\pmod{12}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "constraints = (0, 14), (3, 3), (12, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 14), (3, 3), (12, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $8790$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 5^1\\cdot 293^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(8790))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44692)$.", + "Output Answer": [ + "$22344$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44692))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3372$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3372 % -12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2048^1448 \\pmod{2881}$.", + "Output Answer": [ + "$1712$" + ], + "Output Program": [ + "print(pow(2048, 1448, 2881))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8087$.", + "Output Answer": [ + "$\\{5,7,10,15,17,20,21,28,30,34\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8087):\n if len(roots) == 10: break\n if gcd(a, 8087) == 1 and is_primitive_root(a, 8087):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $285^m \\equiv 1 \\pmod{524}$.", + "Output Answer": [ + "$130$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(285, 524))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6}{1559}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{493 \\sqrt{10}-3}{1559}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6/1559)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-169,595,-703\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -169, 595, -703\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $62778$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 10463^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(62778))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1680^682 \\pmod{2887}$.", + "Output Answer": [ + "$1553$" + ], + "Output Program": [ + "print(pow(1680, 682, 2887))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2774)$.", + "Output Answer": [ + "$1296$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2774))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1129x \\equiv 1 \\pmod{2225}$.", + "Output Answer": [ + "$944$" + ], + "Output Program": [ + "print(pow(1129, -1, 2225))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $68^m \\equiv 1 \\pmod{135}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(68, 135))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $753^284 \\pmod{1815}$.", + "Output Answer": [ + "$1461$" + ], + "Output Program": [ + "print(pow(753, 284, 1815))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n88993", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(88993))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17546)$.", + "Output Answer": [ + "$8460$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17546))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n61441", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(61441))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{3}$\n$x \\equiv 0 \\pmod{4}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 3), (0, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 3), (0, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 3), (0, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{637}{696}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2343433}-637}{1392}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(637/696)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $38^m \\equiv 1 \\pmod{127}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(38, 127))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{7}$\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 20 \\pmod{11}$\n$x \\equiv 3 \\pmod{9}$", + "Output Answer": [ + "$4926$" + ], + "Output Program": [ + "constraints = (12, 7), (16, 10), (20, 11), (3, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 7), (16, 10), (20, 11), (3, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 7), (16, 10), (20, 11), (3, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56794 \\pmod{56}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(56794 % 56)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56022 \\pmod{94}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "print(56022 % 94)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{740,37,-454\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 740, 37, -454\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46544)$.", + "Output Answer": [ + "$23264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46544))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41389)$.", + "Output Answer": [ + "$41388$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41389))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1328^657 \\pmod{2077}$.", + "Output Answer": [ + "$1766$" + ], + "Output Program": [ + "print(pow(1328, 657, 2077))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1619x \\equiv 1 \\pmod{1705}$.", + "Output Answer": [ + "$1249$" + ], + "Output Program": [ + "print(pow(1619, -1, 1705))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{643,376,-849\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 643, 376, -849\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n50837", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(50837))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73141 \\pmod{77}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(73141 % 77)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1371^1734 \\pmod{2095}$.", + "Output Answer": [ + "$1396$" + ], + "Output Program": [ + "print(pow(1371, 1734, 2095))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n26503", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(26503))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4966}{2943}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{14826538}-2483}{2943}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4966/2943)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12396)$.", + "Output Answer": [ + "$4128$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12396))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n21421", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21421))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{7}$\n$x \\equiv 9 \\pmod{2}$\n$x \\equiv 3 \\pmod{10}$", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 7), (9, 2), (3, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 7), (9, 2), (3, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1240x \\equiv 1 \\pmod{1689}$.", + "Output Answer": [ + "$805$" + ], + "Output Program": [ + "print(pow(1240, -1, 1689))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14393 \\pmod{17}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(14393 % 17)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90830 \\pmod{83}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(90830 % 83)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n95987", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(95987))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $545$ is divisible by $14$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(545 % 14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $48858$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(48858 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n64663", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64663))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $667x \\equiv 1 \\pmod{1269}$.", + "Output Answer": [ + "$820$" + ], + "Output Program": [ + "print(pow(667, -1, 1269))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1279^633 \\pmod{2447}$.", + "Output Answer": [ + "$1456$" + ], + "Output Program": [ + "print(pow(1279, 633, 2447))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{302}{1803}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3273610}-151}{1803}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(302/1803)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-12213$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-12213 % -23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n59397", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59397))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{17}$\n$x \\equiv 17 \\pmod{18}$", + "Output Answer": [ + "$251$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 17), (17, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 17), (17, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 17), (17, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36370)$.", + "Output Answer": [ + "$14544$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36370))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{14}$\n$x \\equiv 4 \\pmod{17}$", + "Output Answer": [ + "$208$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 14), (4, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 14), (4, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 14), (4, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10078}{25547}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{678040730}-5039}{25547}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10078/25547)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 1 \\pmod{5}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$96$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 8), (16, 4), (1, 5), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 8), (16, 4), (1, 5), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5175}{4178}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{96603361}-5175}{8356}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5175/4178)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $203x \\equiv 1 \\pmod{205}$.", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "print(pow(203, -1, 205))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31938)$.", + "Output Answer": [ + "$10644$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31938))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7083}{28475}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3293471389}-7083}{56950}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7083/28475)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $16698$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(16698 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $32073$.", + "Output Answer": [ + "$3^1\\cdot 10691^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(32073))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 94287 \\pmod{71}$.", + "Output Answer": [ + "$70$" + ], + "Output Program": [ + "print(94287 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 7), (19, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 7), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 7), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n59181", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(59181))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $716$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(716 % -27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{798,-290\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 798, -290\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{13757}{425}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{850} \\left(\\sqrt{189977549}-13757\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13757/425)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1644}{409}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{409} \\left(\\sqrt{842965}-822\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1644/409)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13658)$.", + "Output Answer": [ + "$6828$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13658))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n64591", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(64591))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47804)$.", + "Output Answer": [ + "$20736$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47804))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $138x \\equiv 1 \\pmod{445}$.", + "Output Answer": [ + "$287$" + ], + "Output Program": [ + "print(pow(138, -1, 445))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84032 \\pmod{13}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(84032 % 13)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4061)$.", + "Output Answer": [ + "$3900$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4061))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{19}$\n$x \\equiv 18 \\pmod{7}$\n$x \\equiv 4 \\pmod{12}$\n$x \\equiv 20 \\pmod{10}$", + "Output Answer": [ + "$3700$" + ], + "Output Program": [ + "constraints = (14, 19), (18, 7), (4, 12), (20, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 19), (18, 7), (4, 12), (20, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n23609", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(23609))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-342,703\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -342, 703\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $847x \\equiv 1 \\pmod{912}$.", + "Output Answer": [ + "$463$" + ], + "Output Program": [ + "print(pow(847, -1, 912))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $71^m \\equiv 1 \\pmod{375}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(71, 375))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $41183$.", + "Output Answer": [ + "$\\{5,7,10,14,15,20,21,23,28,29\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(41183):\n if len(roots) == 10: break\n if gcd(a, 41183) == 1 and is_primitive_root(a, 41183):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31930 \\pmod{9}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(31930 % 9)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n85249", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(85249))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 67879 \\pmod{23}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(67879 % 23)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8489}{3786}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{447745}-8489}{7572}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8489/3786)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3375}{2123}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{29419141}-3375}{4246}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3375/2123)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43743 \\pmod{97}$.", + "Output Answer": [ + "$93$" + ], + "Output Program": [ + "print(43743 % 97)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63884 \\pmod{88}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "print(63884 % 88)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-451,-444\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -451, -444\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $42_{27}$ to base 10.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "n = '42'.strip('.')\nbase = 27\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 7 \\pmod{9}$\n$x \\equiv 18 \\pmod{16}$", + "Output Answer": [ + "$610$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 7), (7, 9), (18, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 7), (7, 9), (18, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 7), (7, 9), (18, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $74x \\equiv 1 \\pmod{751}$.", + "Output Answer": [ + "$477$" + ], + "Output Program": [ + "print(pow(74, -1, 751))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $25668$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(25668 % -31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-6034$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-6034 % -14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $67^m \\equiv 1 \\pmod{430}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(67, 430))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{229,839,319\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 229, 839, 319\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2024^1964 \\pmod{2997}$.", + "Output Answer": [ + "$2674$" + ], + "Output Program": [ + "print(pow(2024, 1964, 2997))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $557^m \\equiv 1 \\pmod{590}$.", + "Output Answer": [ + "$116$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(557, 590))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $50_7$ to base 10.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "n = '50'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10382}{2863}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1405730}-5191}{2863}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10382/2863)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{411}{325}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{650} \\left(\\sqrt{591421}-411\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(411/325)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2465^2154 \\pmod{2561}$.", + "Output Answer": [ + "$142$" + ], + "Output Program": [ + "print(pow(2465, 2154, 2561))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-230,241,-560\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -230, 241, -560\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2599$ to base $14$.", + "Output Answer": [ + "$\\text{d39}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2599\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $881^m \\equiv 1 \\pmod{968}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(881, 968))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.99$ to base $4$.", + "Output Answer": [ + "$0.3331130022_4$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 4\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.99\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{17}$\n$x \\equiv 20 \\pmod{3}$", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 17), (20, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 17), (20, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 17), (20, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $2240$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2240 % -8 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n27089", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(27089))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(5459)$.", + "Output Answer": [ + "$5304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(5459))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69001 \\pmod{37}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(69001 % 37)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89283 \\pmod{35}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(89283 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $243^m \\equiv 1 \\pmod{784}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(243, 784))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9655}{6986}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{288435809}-9655}{13972}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9655/6986)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{7}$\n$x \\equiv 6 \\pmod{5}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "constraints = (16, 7), (6, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (16, 7), (6, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 7), (6, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17273)$.", + "Output Answer": [ + "$16500$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17273))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{11898}{5179}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{62212642}-5949}{5179}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(11898/5179)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1658$ to base $9$.", + "Output Answer": [ + "$2242_9$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 9\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1658\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $305^m \\equiv 1 \\pmod{464}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(305, 464))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{99,853,478\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 99, 853, 478\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6993}{11362}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{22611289}-6993}{22724}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6993/11362)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1568^2108 \\pmod{1869}$.", + "Output Answer": [ + "$1603$" + ], + "Output Program": [ + "print(pow(1568, 2108, 1869))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1855x \\equiv 1 \\pmod{1962}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(pow(1855, -1, 1962))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $815x \\equiv 1 \\pmod{1614}$.", + "Output Answer": [ + "$101$" + ], + "Output Program": [ + "print(pow(815, -1, 1614))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $227^m \\equiv 1 \\pmod{498}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(227, 498))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $53^m \\equiv 1 \\pmod{185}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(53, 185))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $28704$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(28704 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n2789", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2789))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14723 \\pmod{26}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(14723 % 26)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $233^m \\equiv 1 \\pmod{607}$.", + "Output Answer": [ + "$303$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(233, 607))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52180 \\pmod{54}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(52180 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $897x \\equiv 1 \\pmod{1484}$.", + "Output Answer": [ + "$225$" + ], + "Output Program": [ + "print(pow(897, -1, 1484))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $660x \\equiv 1 \\pmod{689}$.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "print(pow(660, -1, 689))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $451^m \\equiv 1 \\pmod{504}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(451, 504))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $5x \\equiv 1 \\pmod{342}$.", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "print(pow(5, -1, 342))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44441)$.", + "Output Answer": [ + "$42084$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44441))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5358$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(5358 % -18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n48463", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(48463))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48905)$.", + "Output Answer": [ + "$39120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48905))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $98$ is divisible by $47$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(98 % 47 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n24391", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(24391))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $709x \\equiv 1 \\pmod{1009}$.", + "Output Answer": [ + "$972$" + ], + "Output Program": [ + "print(pow(709, -1, 1009))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{796,-565\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 796, -565\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $151^m \\equiv 1 \\pmod{292}$.", + "Output Answer": [ + "$72$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(151, 292))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38165)$.", + "Output Answer": [ + "$28672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38165))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-740,-917,691\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -740, -917, 691\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $425x \\equiv 1 \\pmod{1127}$.", + "Output Answer": [ + "$297$" + ], + "Output Program": [ + "print(pow(425, -1, 1127))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8880$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8880 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $925$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(925 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $232x \\equiv 1 \\pmod{1259}$.", + "Output Answer": [ + "$852$" + ], + "Output Program": [ + "print(pow(232, -1, 1259))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17352}{23759}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{17 \\sqrt{2213713}-8676}{23759}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17352/23759)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1672$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1672 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-243,-426,463\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -243, -426, 463\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12573}{12247}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{758036365}-12573}{24494}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12573/12247)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n22127", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(22127))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-59408$ is divisible by $-47$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-59408 % -47 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $9767$.", + "Output Answer": [ + "$\\{5,7,10,15,19,20,21,28,30,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(9767):\n if len(roots) == 10: break\n if gcd(a, 9767) == 1 and is_primitive_root(a, 9767):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1056^2300 \\pmod{2993}$.", + "Output Answer": [ + "$985$" + ], + "Output Program": [ + "print(pow(1056, 2300, 2993))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1154^1566 \\pmod{2046}$.", + "Output Answer": [ + "$562$" + ], + "Output Program": [ + "print(pow(1154, 1566, 2046))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $251^m \\equiv 1 \\pmod{516}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(251, 516))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n54325", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54325))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-455,-869\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -455, -869\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $77^m \\equiv 1 \\pmod{449}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(77, 449))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $3003$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(3003 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $172^40 \\pmod{1924}$.", + "Output Answer": [ + "$848$" + ], + "Output Program": [ + "print(pow(172, 40, 1924))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-745,-530,651\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -745, -530, 651\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-906,251,-578\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -906, 251, -578\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $31^m \\equiv 1 \\pmod{119}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(31, 119))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $67161$.", + "Output Answer": [ + "$3^1\\cdot 61^1\\cdot 367^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(67161))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1994^1214 \\pmod{2956}$.", + "Output Answer": [ + "$488$" + ], + "Output Program": [ + "print(pow(1994, 1214, 2956))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 26202 \\pmod{58}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(26202 % 58)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{5}$\n$x \\equiv 2 \\pmod{6}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 5), (2, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 5), (2, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 5), (2, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{626,333,-209\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 626, 333, -209\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.363$ to base $7$.", + "Output Answer": [ + "$0.2353364_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.363\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-25235$ is divisible by $-35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-25235 % -35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 57597 \\pmod{57}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(57597 % 57)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 68911 \\pmod{10}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(68911 % 10)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $14323_5$ to base 10.", + "Output Answer": [ + "$1213$" + ], + "Output Program": [ + "n = '14323'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n10911", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(10911))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 20 \\pmod{7}$", + "Output Answer": [ + "$496$" + ], + "Output Program": [ + "import math\n\nconstraints = (12, 11), (16, 8), (20, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 11), (16, 8), (20, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 11), (16, 8), (20, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $290^m \\equiv 1 \\pmod{651}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(290, 651))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1909x \\equiv 1 \\pmod{2335}$.", + "Output Answer": [ + "$729$" + ], + "Output Program": [ + "print(pow(1909, -1, 2335))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $419x \\equiv 1 \\pmod{1787}$.", + "Output Answer": [ + "$1143$" + ], + "Output Program": [ + "print(pow(419, -1, 1787))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $181^m \\equiv 1 \\pmod{470}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(181, 470))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $859x \\equiv 1 \\pmod{2107}$.", + "Output Answer": [ + "$1977$" + ], + "Output Program": [ + "print(pow(859, -1, 2107))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $467x \\equiv 1 \\pmod{940}$.", + "Output Answer": [ + "$783$" + ], + "Output Program": [ + "print(pow(467, -1, 940))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{19}$\n$x \\equiv 2 \\pmod{5}$\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 10 \\pmod{16}$", + "Output Answer": [ + "$10842$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 19), (2, 5), (7, 11), (10, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 19), (2, 5), (7, 11), (10, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 19), (2, 5), (7, 11), (10, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-62440$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-62440 % -40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $309^m \\equiv 1 \\pmod{976}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(309, 976))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $105^m \\equiv 1 \\pmod{211}$.", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(105, 211))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $407^m \\equiv 1 \\pmod{663}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(407, 663))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $169x \\equiv 1 \\pmod{259}$.", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "print(pow(169, -1, 259))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 74505 \\pmod{90}$.", + "Output Answer": [ + "$75$" + ], + "Output Program": [ + "print(74505 % 90)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-371,-835,-802\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -371, -835, -802\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-806,-930,538\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -806, -930, 538\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{19}$\n$x \\equiv 15 \\pmod{12}$\n$x \\equiv 15 \\pmod{18}$", + "Output Answer": [ + "$627$" + ], + "Output Program": [ + "constraints = (19, 19), (15, 12), (15, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 19), (15, 12), (15, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{5}$\n$x \\equiv 2 \\pmod{13}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "constraints = (17, 5), (2, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 5), (2, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 5), (2, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.568$ to base $7$.", + "Output Answer": [ + "$0.3655524_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.568\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{3}$\n$x \\equiv 19 \\pmod{2}$\n$x \\equiv 8 \\pmod{5}$", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 3), (19, 2), (8, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 3), (19, 2), (8, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 3), (19, 2), (8, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $75202$.", + "Output Answer": [ + "$2^1\\cdot 19^1\\cdot 1979^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(75202))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54142 \\pmod{46}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(54142 % 46)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7411$.", + "Output Answer": [ + "$\\{2,3,10,14,15,21,34,39,43,47\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7411):\n if len(roots) == 10: break\n if gcd(a, 7411) == 1 and is_primitive_root(a, 7411):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{7}$\n$x \\equiv 11 \\pmod{6}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 7), (11, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 7), (11, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (4, 7), (11, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48363 \\pmod{52}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(48363 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1189^1477 \\pmod{1463}$.", + "Output Answer": [ + "$1189$" + ], + "Output Program": [ + "print(pow(1189, 1477, 1463))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47499)$.", + "Output Answer": [ + "$31080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47499))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1308}{715}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{715} \\left(\\sqrt{938941}-654\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1308/715)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-153,-392\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -153, -392\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50719 \\pmod{48}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(50719 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $429^m \\equiv 1 \\pmod{818}$.", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(429, 818))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-746,652\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -746, 652\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{8,1,-377\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 8, 1, -377\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 13 \\pmod{4}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "constraints = (6, 11), (13, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (6, 11), (13, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 11), (13, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69448 \\pmod{30}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(69448 % 30)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n733", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(733))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 65867 \\pmod{28}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(65867 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72031 \\pmod{98}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(72031 % 98)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-724,494\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -724, 494\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $81^m \\equiv 1 \\pmod{716}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(81, 716))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n58611", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(58611))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2028^1526 \\pmod{2695}$.", + "Output Answer": [ + "$1929$" + ], + "Output Program": [ + "print(pow(2028, 1526, 2695))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $259$ is divisible by $7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(259 % 7 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $127^m \\equiv 1 \\pmod{642}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(127, 642))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15305}{18518}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1605908321}-15305}{37036}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15305/18518)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{20}$\n$x \\equiv 7 \\pmod{7}$", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 20), (7, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 20), (7, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 20), (7, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $374$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(374 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-279$ is divisible by $26$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-279 % 26 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $13260$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(13260 % -26 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8642$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8642 % 29 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{614,291\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 614, 291\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{16}$\n$x \\equiv 0 \\pmod{2}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 16), (0, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 16), (0, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n55101", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(55101))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{665,-343\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 665, -343\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52655 \\pmod{80}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(52655 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{713,792,-31\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 713, 792, -31\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $103^m \\equiv 1 \\pmod{157}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(103, 157))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n84183", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(84183))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $707$ is divisible by $35$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(707 % 35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 9980 \\pmod{100}$.", + "Output Answer": [ + "$80$" + ], + "Output Program": [ + "print(9980 % 100)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $45^m \\equiv 1 \\pmod{286}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(45, 286))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $49_{27}$ to base 10.", + "Output Answer": [ + "$117$" + ], + "Output Program": [ + "n = '49'.strip('.')\nbase = 27\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-847$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-847 % -11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 34680 \\pmod{49}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(34680 % 49)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{24223}{9234}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{927820753}-24223}{18468}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(24223/9234)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22687)$.", + "Output Answer": [ + "$19404$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22687))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 89687 \\pmod{17}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(89687 % 17)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55009 \\pmod{79}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(55009 % 79)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $287^m \\equiv 1 \\pmod{759}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(287, 759))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{446,-875\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 446, -875\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1756^1653 \\pmod{2938}$.", + "Output Answer": [ + "$1860$" + ], + "Output Program": [ + "print(pow(1756, 1653, 2938))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $757x \\equiv 1 \\pmod{2325}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "print(pow(757, -1, 2325))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{15}$\n$x \\equiv 18 \\pmod{6}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (18, 15), (18, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (18, 15), (18, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35101 \\pmod{100}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(35101 % 100)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $185x \\equiv 1 \\pmod{378}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(pow(185, -1, 378))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23297)$.", + "Output Answer": [ + "$23296$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23297))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-9660$ is divisible by $14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9660 % 14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $38x \\equiv 1 \\pmod{179}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(pow(38, -1, 179))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{16313}{885}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{269246869}-16313}{1770}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16313/885)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-184$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-184 % 48 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $731x \\equiv 1 \\pmod{1595}$.", + "Output Answer": [ + "$1571$" + ], + "Output Program": [ + "print(pow(731, -1, 1595))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{20}$\n$x \\equiv 8 \\pmod{12}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (0, 20), (8, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 20), (8, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.92$ to base $7$.", + "Output Answer": [ + "$0.630363_7$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 7\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.92\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45573)$.", + "Output Answer": [ + "$27600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45573))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1076^2217 \\pmod{1339}$.", + "Output Answer": [ + "$207$" + ], + "Output Program": [ + "print(pow(1076, 2217, 1339))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{20}$\n$x \\equiv 8 \\pmod{18}$", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "constraints = (2, 20), (8, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (2, 20), (8, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1069^2342 \\pmod{1528}$.", + "Output Answer": [ + "$1385$" + ], + "Output Program": [ + "print(pow(1069, 2342, 1528))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2462^1865 \\pmod{2944}$.", + "Output Answer": [ + "$2048$" + ], + "Output Program": [ + "print(pow(2462, 1865, 2944))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $546$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(546 % -16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2074^467 \\pmod{2566}$.", + "Output Answer": [ + "$204$" + ], + "Output Program": [ + "print(pow(2074, 467, 2566))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.51$ to base $6$.", + "Output Answer": [ + "$0.30205432_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.51\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4399}{2945}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{54043301}-4399}{5890}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4399/2945)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-309,138,131\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -309, 138, 131\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{613,618,119\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 613, 618, 119\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27708 \\pmod{56}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(27708 % 56)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3489}{25889}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2693134405}-3489}{51778}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3489/25889)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $191_{33}$ to base 10.", + "Output Answer": [ + "$1387$" + ], + "Output Program": [ + "n = '191'.strip('.')\nbase = 33\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79530 \\pmod{15}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(79530 % 15)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n54051", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(54051))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 7 \\pmod{13}$\n$x \\equiv 20 \\pmod{15}$", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "constraints = (7, 2), (7, 13), (20, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 2), (7, 13), (20, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 2), (7, 13), (20, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $388x \\equiv 1 \\pmod{907}$.", + "Output Answer": [ + "$180$" + ], + "Output Program": [ + "print(pow(388, -1, 907))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{23952}{13717}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{331580665}-11976}{13717}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23952/13717)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1970^1906 \\pmod{2907}$.", + "Output Answer": [ + "$1738$" + ], + "Output Program": [ + "print(pow(1970, 1906, 2907))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7880}{2913}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{24009169}-3940}{2913}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7880/2913)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-22632$ is divisible by $24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-22632 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93804 \\pmod{84}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(93804 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $61x \\equiv 1 \\pmod{1036}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(61, -1, 1036))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-930,-284\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -930, -284\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43661)$.", + "Output Answer": [ + "$43660$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43661))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $246x \\equiv 1 \\pmod{1565}$.", + "Output Answer": [ + "$1266$" + ], + "Output Program": [ + "print(pow(246, -1, 1565))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n97453", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97453))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3369 \\pmod{58}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(3369 % 58)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 98744 \\pmod{52}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(98744 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90783 \\pmod{23}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(90783 % 23)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $433$ to base $8$.", + "Output Answer": [ + "$661_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 433\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 13133 \\pmod{100}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(13133 % 100)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $429x \\equiv 1 \\pmod{535}$.", + "Output Answer": [ + "$429$" + ], + "Output Program": [ + "print(pow(429, -1, 535))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $985x \\equiv 1 \\pmod{1971}$.", + "Output Answer": [ + "$1969$" + ], + "Output Program": [ + "print(pow(985, -1, 1971))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 15 \\pmod{7}$", + "Output Answer": [ + "$400$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 13), (15, 11), (15, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 13), (15, 11), (15, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 13), (15, 11), (15, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $37x \\equiv 1 \\pmod{1140}$.", + "Output Answer": [ + "$493$" + ], + "Output Program": [ + "print(pow(37, -1, 1140))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $928^495 \\pmod{2957}$.", + "Output Answer": [ + "$2882$" + ], + "Output Program": [ + "print(pow(928, 495, 2957))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{20}$\n$x \\equiv 10 \\pmod{6}$", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 20), (10, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 20), (10, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n90075", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(90075))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{47982}{23369}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1121678242}-23991}{23369}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(47982/23369)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $7481$.", + "Output Answer": [ + "$\\{6,7,12,13,14,19,24,26,28,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(7481):\n if len(roots) == 10: break\n if gcd(a, 7481) == 1 and is_primitive_root(a, 7481):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n86587", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(86587))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2548)$.", + "Output Answer": [ + "$1008$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2548))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $749$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(749 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 16 \\pmod{7}$\n$x \\equiv 2 \\pmod{18}$", + "Output Answer": [ + "$1136$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 11), (16, 7), (2, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 11), (16, 7), (2, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (14, 11), (16, 7), (2, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1703^1711 \\pmod{1744}$.", + "Output Answer": [ + "$695$" + ], + "Output Program": [ + "print(pow(1703, 1711, 1744))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $88741$.", + "Output Answer": [ + "$88741^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(88741))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1799$ is divisible by $43$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1799 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-948,900,77\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -948, 900, 77\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2230$ to base $20$.", + "Output Answer": [ + "$\\text{5ba}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2230\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(23009)$.", + "Output Answer": [ + "$18576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(23009))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{107,-829\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 107, -829\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86151 \\pmod{64}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(86151 % 64)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56707 \\pmod{11}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(56707 % 11)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{661,-17\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 661, -17\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{17}$\n$x \\equiv 2 \\pmod{16}$", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "constraints = (12, 17), (2, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 17), (2, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 17), (2, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $893x \\equiv 1 \\pmod{2140}$.", + "Output Answer": [ + "$937$" + ], + "Output Program": [ + "print(pow(893, -1, 2140))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{19}$\n$x \\equiv 12 \\pmod{9}$", + "Output Answer": [ + "$111$" + ], + "Output Program": [ + "import math\n\nconstraints = (16, 19), (12, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 19), (12, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 19), (12, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{578,-663\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 578, -663\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $457x \\equiv 1 \\pmod{2070}$.", + "Output Answer": [ + "$1993$" + ], + "Output Program": [ + "print(pow(457, -1, 2070))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $255_{13}$ to base 10.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "n = '255'.strip('.')\nbase = 13\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1983}{2993}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{39764485}-1983}{5986}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1983/2993)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20922)$.", + "Output Answer": [ + "$6320$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{675}{4763}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{91200301}-675}{9526}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(675/4763)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{151}{343}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{686} \\left(\\sqrt{493397}-151\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(151/343)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6007}{10038}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{17565193}-6007}{20076}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6007/10038)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $229^m \\equiv 1 \\pmod{711}$.", + "Output Answer": [ + "$78$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(229, 711))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-987,-819\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -987, -819\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{10}$\n$x \\equiv 11 \\pmod{19}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 10), (11, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 10), (11, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 10), (11, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 10 \\pmod{8}$", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 11), (10, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (16, 11), (10, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (16, 11), (10, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1707^827 \\pmod{1969}$.", + "Output Answer": [ + "$1613$" + ], + "Output Program": [ + "print(pow(1707, 827, 1969))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{241,-953,175\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 241, -953, 175\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80757 \\pmod{40}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(80757 % 40)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1511$ to base $5$.", + "Output Answer": [ + "$22021_5$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 5\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1511\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48830)$.", + "Output Answer": [ + "$18432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48830))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-777,-71,118\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -777, -71, 118\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $781$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(781 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1320^2346 \\pmod{2917}$.", + "Output Answer": [ + "$1478$" + ], + "Output Program": [ + "print(pow(1320, 2346, 2917))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12808)$.", + "Output Answer": [ + "$6400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12808))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24541)$.", + "Output Answer": [ + "$21120$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24541))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11073)$.", + "Output Answer": [ + "$7380$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11073))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $138$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(138 % 6 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $12241$.", + "Output Answer": [ + "$\\{7,13,14,21,26,29,31,42,43,46\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(12241):\n if len(roots) == 10: break\n if gcd(a, 12241) == 1 and is_primitive_root(a, 12241):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-781,817\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -781, 817\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{134,682,-281\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 134, 682, -281\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.04006114_7$ to base 10.", + "Output Answer": [ + "$0.082$" + ], + "Output Program": [ + "n = '0.04006114'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{16}$\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 19 \\pmod{13}$", + "Output Answer": [ + "$890$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 16), (5, 15), (19, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 16), (5, 15), (19, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 16), (5, 15), (19, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-4,-3,-3,-2\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = -4, -3, -3, -2\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $73002$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(73002 % -46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.0001110101110000101001_2$ to base 10.", + "Output Answer": [ + "$0.115$" + ], + "Output Program": [ + "n = '0.0001110101110000101001'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{16}$\n$x \\equiv 15 \\pmod{9}$", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "constraints = (6, 16), (15, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 16), (15, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 16), (15, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $86^m \\equiv 1 \\pmod{361}$.", + "Output Answer": [ + "$342$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(86, 361))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $257x \\equiv 1 \\pmod{306}$.", + "Output Answer": [ + "$281$" + ], + "Output Program": [ + "print(pow(257, -1, 306))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 60268 \\pmod{39}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(60268 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 2 \\pmod{10}$", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "import math\n\nconstraints = (10, 13), (2, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 13), (2, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 13), (2, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1837^2230 \\pmod{2326}$.", + "Output Answer": [ + "$1309$" + ], + "Output Program": [ + "print(pow(1837, 2230, 2326))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7141)$.", + "Output Answer": [ + "$6912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7141))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40772 \\pmod{72}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(40772 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $925^931 \\pmod{1621}$.", + "Output Answer": [ + "$887$" + ], + "Output Program": [ + "print(pow(925, 931, 1621))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{623,165,614\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 623, 165, 614\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40045 \\pmod{78}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(40045 % 78)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $577x \\equiv 1 \\pmod{591}$.", + "Output Answer": [ + "$211$" + ], + "Output Program": [ + "print(pow(577, -1, 591))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2181^1806 \\pmod{2346}$.", + "Output Answer": [ + "$729$" + ], + "Output Program": [ + "print(pow(2181, 1806, 2346))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $116^43 \\pmod{2184}$.", + "Output Answer": [ + "$1208$" + ], + "Output Program": [ + "print(pow(116, 43, 2184))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{88}{21}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{21} \\left(\\sqrt{2377}-44\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(88/21)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 353 \\pmod{72}$.", + "Output Answer": [ + "$65$" + ], + "Output Program": [ + "print(353 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46411 \\pmod{9}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(46411 % 9)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $963x \\equiv 1 \\pmod{1454}$.", + "Output Answer": [ + "$459$" + ], + "Output Program": [ + "print(pow(963, -1, 1454))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2399^785 \\pmod{2872}$.", + "Output Answer": [ + "$1999$" + ], + "Output Program": [ + "print(pow(2399, 785, 2872))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{363,285,74\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 363, 285, 74\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34140)$.", + "Output Answer": [ + "$9088$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34140))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n76157", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76157))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $885x \\equiv 1 \\pmod{904}$.", + "Output Answer": [ + "$333$" + ], + "Output Program": [ + "print(pow(885, -1, 904))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7308)$.", + "Output Answer": [ + "$2016$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7308))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-83$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-83 % -7 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $162^m \\equiv 1 \\pmod{619}$.", + "Output Answer": [ + "$618$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(162, 619))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{753,470,-432\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 753, 470, -432\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{7}$\n$x \\equiv 5 \\pmod{10}$", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 7), (5, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 7), (5, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 7), (5, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(24420)$.", + "Output Answer": [ + "$5760$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(24420))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{186}{173}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{173} \\left(\\sqrt{38578}-93\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(186/173)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{16397}{4181}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{338784653}-16397}{8362}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16397/4181)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $18638$.", + "Output Answer": [ + "$\\{3,7,13,17,23,29,33,35,41,63\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(18638):\n if len(roots) == 10: break\n if gcd(a, 18638) == 1 and is_primitive_root(a, 18638):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8111}{9914}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{29 \\sqrt{545705}-8111}{19828}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8111/9914)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,-2,-3\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = -1, -2, -3\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $351x \\equiv 1 \\pmod{1922}$.", + "Output Answer": [ + "$679$" + ], + "Output Program": [ + "print(pow(351, -1, 1922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $3223$.", + "Output Answer": [ + "$11^1\\cdot 293^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(3223))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.515$ to base $15$.", + "Output Answer": [ + "$\\text{0.7ad1d}_{15}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 15\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.515\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{197,125,276\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 197, 125, 276\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1763$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1763 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3988}{4435}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{23645261}-1994}{4435}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3988/4435)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 18 \\pmod{11}$", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 3), (18, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 3), (18, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 3), (18, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $164x \\equiv 1 \\pmod{483}$.", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "print(pow(164, -1, 483))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1432^68 \\pmod{2133}$.", + "Output Answer": [ + "$1000$" + ], + "Output Program": [ + "print(pow(1432, 68, 2133))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-445$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-445 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2428$ to base $13$.", + "Output Answer": [ + "$\\text{114a}_{13}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 13\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2428\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 11 \\pmod{4}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (16, 3), (11, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 11), (16, 3), (11, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 11), (16, 3), (11, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{502,-948\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 502, -948\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $233^m \\equiv 1 \\pmod{924}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(233, 924))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $324^822 \\pmod{2142}$.", + "Output Answer": [ + "$1548$" + ], + "Output Program": [ + "print(pow(324, 822, 2142))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-40887$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-40887 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1092^186 \\pmod{1206}$.", + "Output Answer": [ + "$558$" + ], + "Output Program": [ + "print(pow(1092, 186, 1206))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $493^1482 \\pmod{2345}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(pow(493, 1482, 2345))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $39419$.", + "Output Answer": [ + "$\\{2,6,7,8,10,18,21,22,24,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(39419):\n if len(roots) == 10: break\n if gcd(a, 39419) == 1 and is_primitive_root(a, 39419):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16501)$.", + "Output Answer": [ + "$15904$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16501))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1075x \\equiv 1 \\pmod{1352}$.", + "Output Answer": [ + "$1147$" + ], + "Output Program": [ + "print(pow(1075, -1, 1352))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $957x \\equiv 1 \\pmod{2366}$.", + "Output Answer": [ + "$759$" + ], + "Output Program": [ + "print(pow(957, -1, 2366))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53902 \\pmod{40}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(53902 % 40)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19233 \\pmod{46}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(19233 % 46)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 24119 \\pmod{63}$.", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "print(24119 % 63)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1963}{1519}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{13082813}-1963}{3038}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1963/1519)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-119511$ is divisible by $-49$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-119511 % -49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $47^m \\equiv 1 \\pmod{399}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(47, 399))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $495^m \\equiv 1 \\pmod{536}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(495, 536))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2337^2265 \\pmod{2495}$.", + "Output Answer": [ + "$842$" + ], + "Output Program": [ + "print(pow(2337, 2265, 2495))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1833^1653 \\pmod{2840}$.", + "Output Answer": [ + "$2633$" + ], + "Output Program": [ + "print(pow(1833, 1653, 2840))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n34259", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(34259))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{13438}{5523}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{75648490}-6719}{5523}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13438/5523)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 16198 \\pmod{32}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "print(16198 % 32)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $12^1373 \\pmod{1300}$.", + "Output Answer": [ + "$272$" + ], + "Output Program": [ + "print(pow(12, 1373, 1300))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $20000_3$ to base 10.", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "n = '20000'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $10067$.", + "Output Answer": [ + "$\\{2,5,6,7,8,13,15,17,18,19\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(10067):\n if len(roots) == 10: break\n if gcd(a, 10067) == 1 and is_primitive_root(a, 10067):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n58401", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(58401))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{12}$\n$x \\equiv 19 \\pmod{15}$", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 12), (19, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 12), (19, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{20}$\n$x \\equiv 2 \\pmod{7}$", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 20), (2, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 20), (2, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 20), (2, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $7720$ is divisible by $20$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7720 % 20 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $103^m \\equiv 1 \\pmod{948}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(103, 948))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84741 \\pmod{76}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(84741 % 76)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $18^m \\equiv 1 \\pmod{487}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(18, 487))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $529x \\equiv 1 \\pmod{2366}$.", + "Output Answer": [ + "$653$" + ], + "Output Program": [ + "print(pow(529, -1, 2366))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35406)$.", + "Output Answer": [ + "$10080$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35406))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2632}{29917}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{896758745}-1316}{29917}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2632/29917)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $497^600 \\pmod{1390}$.", + "Output Answer": [ + "$701$" + ], + "Output Program": [ + "print(pow(497, 600, 1390))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $856^1507 \\pmod{941}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(pow(856, 1507, 941))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{8}$\n$x \\equiv 13 \\pmod{5}$", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 8), (13, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (3, 8), (13, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (3, 8), (13, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-970,678\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -970, 678\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-17802$ is divisible by $46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-17802 % 46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n2699", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(2699))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $627x \\equiv 1 \\pmod{1970}$.", + "Output Answer": [ + "$1483$" + ], + "Output Program": [ + "print(pow(627, -1, 1970))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.845$ to base $20$.", + "Output Answer": [ + "$\\text{0.gi}_{20}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 20\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.845\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $78388$.", + "Output Answer": [ + "$2^2\\cdot 19597^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(78388))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48078 \\pmod{7}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(48078 % 7)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $850^2362 \\pmod{903}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(850, 2362, 903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $10x \\equiv 1 \\pmod{43}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(pow(10, -1, 43))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-389,695,-918\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -389, 695, -918\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{20003}{20257}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2041504205}-20003}{40514}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20003/20257)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 16 \\pmod{9}$\n$x \\equiv 10 \\pmod{15}$", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (16, 9), (10, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 14), (16, 9), (10, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $9^m \\equiv 1 \\pmod{178}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(9, 178))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{11}$\n$x \\equiv 1 \\pmod{17}$\n$x \\equiv 4 \\pmod{13}$\n$x \\equiv 10 \\pmod{2}$", + "Output Answer": [ + "$2058$" + ], + "Output Program": [ + "import math\n\nconstraints = (12, 11), (1, 17), (4, 13), (10, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 11), (1, 17), (4, 13), (10, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 11), (1, 17), (4, 13), (10, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.87$ to base $36$.", + "Output Answer": [ + "$\\text{0.vbiq}_{36}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 36\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.87\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $325^m \\equiv 1 \\pmod{404}$.", + "Output Answer": [ + "$50$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(325, 404))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13506)$.", + "Output Answer": [ + "$4500$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13506))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $116x \\equiv 1 \\pmod{247}$.", + "Output Answer": [ + "$181$" + ], + "Output Program": [ + "print(pow(116, -1, 247))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1980$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1980 % 18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46987)$.", + "Output Answer": [ + "$44496$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46987))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1217$ to base $29$.", + "Output Answer": [ + "$\\text{1cs}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1217\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $35910$ is divisible by $35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(35910 % 35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $279^m \\equiv 1 \\pmod{346}$.", + "Output Answer": [ + "$43$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(279, 346))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{20}$\n$x \\equiv 19 \\pmod{8}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 11 \\pmod{14}$", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "constraints = (15, 20), (19, 8), (3, 4), (11, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 20), (19, 8), (3, 4), (11, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1633x \\equiv 1 \\pmod{1665}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "print(pow(1633, -1, 1665))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-2100$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-2100 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $6025_7$ to base 10.", + "Output Answer": [ + "$2077$" + ], + "Output Program": [ + "n = '6025'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9649}{20462}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1767876977}-9649}{40924}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9649/20462)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(4796)$.", + "Output Answer": [ + "$2160$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(4796))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32154)$.", + "Output Answer": [ + "$10208$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32154))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2476^1677 \\pmod{2787}$.", + "Output Answer": [ + "$163$" + ], + "Output Program": [ + "print(pow(2476, 1677, 2787))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $358^209 \\pmod{718}$.", + "Output Answer": [ + "$358$" + ], + "Output Program": [ + "print(pow(358, 209, 718))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $11010000111_2$ to base 10.", + "Output Answer": [ + "$1671$" + ], + "Output Program": [ + "n = '11010000111'.strip('.')\nbase = 2\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $119^m \\equiv 1 \\pmod{261}$.", + "Output Answer": [ + "$84$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(119, 261))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-83,8,33\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -83, 8, 33\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2006^1551 \\pmod{2237}$.", + "Output Answer": [ + "$1274$" + ], + "Output Program": [ + "print(pow(2006, 1551, 2237))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{7}$\n$x \\equiv 7 \\pmod{2}$", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 7), (7, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 7), (7, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 7), (7, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-180$ is divisible by $-10$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-180 % -10 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12764)$.", + "Output Answer": [ + "$6380$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12764))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $703^2368 \\pmod{1596}$.", + "Output Answer": [ + "$361$" + ], + "Output Program": [ + "print(pow(703, 2368, 1596))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.15$ to base $3$.", + "Output Answer": [ + "$0.01100110011001_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.15\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(28346)$.", + "Output Answer": [ + "$14172$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(28346))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{968,-447\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 968, -447\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $89x \\equiv 1 \\pmod{255}$.", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "print(pow(89, -1, 255))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $395x \\equiv 1 \\pmod{427}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(pow(395, -1, 427))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 11 \\pmod{13}$", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "constraints = (11, 7), (11, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (11, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 7), (11, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $267^m \\equiv 1 \\pmod{454}$.", + "Output Answer": [ + "$113$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(267, 454))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $876^2313 \\pmod{1661}$.", + "Output Answer": [ + "$805$" + ], + "Output Program": [ + "print(pow(876, 2313, 1661))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-655$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-655 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-11169$ is divisible by $17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-11169 % 17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1394^878 \\pmod{2569}$.", + "Output Answer": [ + "$743$" + ], + "Output Program": [ + "print(pow(1394, 878, 2569))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $233^m \\equiv 1 \\pmod{482}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(233, 482))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $773^1055 \\pmod{1733}$.", + "Output Answer": [ + "$1409$" + ], + "Output Program": [ + "print(pow(773, 1055, 1733))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2875}{15798}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1006572841}-2875}{31596}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2875/15798)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41272)$.", + "Output Answer": [ + "$15840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41272))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9985}{35004}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{5000820289}-9985}{70008}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9985/35004)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $145^m \\equiv 1 \\pmod{336}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(145, 336))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{10}$\n$x \\equiv 19 \\pmod{4}$\n$x \\equiv 8 \\pmod{19}$", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 10), (19, 4), (8, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 10), (19, 4), (8, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n82033", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(82033))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4543}{15165}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{940547749}-4543}{30330}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4543/15165)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64430 \\pmod{6}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(64430 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55294 \\pmod{100}$.", + "Output Answer": [ + "$94$" + ], + "Output Program": [ + "print(55294 % 100)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-240$ is divisible by $-11$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-240 % -11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $327^m \\equiv 1 \\pmod{485}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(327, 485))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 64861 \\pmod{100}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(64861 % 100)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $8130$ is divisible by $15$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(8130 % 15 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 12200 \\pmod{19}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(12200 % 19)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31172 \\pmod{41}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(31172 % 41)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{497,70\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 497, 70\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{34951}{39839}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7570156085}-34951}{79678}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34951/39839)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{822,292,-995\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 822, 292, -995\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $316^1452 \\pmod{2865}$.", + "Output Answer": [ + "$451$" + ], + "Output Program": [ + "print(pow(316, 1452, 2865))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{14}$\n$x \\equiv 13 \\pmod{11}$\n$x \\equiv 0 \\pmod{12}$\n$x \\equiv 20 \\pmod{20}$", + "Output Answer": [ + "$3720$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 14), (13, 11), (0, 12), (20, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 14), (13, 11), (0, 12), (20, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1777^1648 \\pmod{2127}$.", + "Output Answer": [ + "$934$" + ], + "Output Program": [ + "print(pow(1777, 1648, 2127))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n96905", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(96905))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $269_{29}$ to base 10.", + "Output Answer": [ + "$1865$" + ], + "Output Program": [ + "n = '269'.strip('.')\nbase = 29\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1394$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1394 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n32215", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(32215))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-27225$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-27225 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $459x \\equiv 1 \\pmod{659}$.", + "Output Answer": [ + "$458$" + ], + "Output Program": [ + "print(pow(459, -1, 659))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{19}$\n$x \\equiv 0 \\pmod{11}$\n$x \\equiv 11 \\pmod{20}$", + "Output Answer": [ + "$1551$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 19), (0, 11), (11, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (12, 19), (0, 11), (11, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (12, 19), (0, 11), (11, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1040$ to base $29$.", + "Output Answer": [ + "$\\text{16p}_{29}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 29\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1040\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4462}{1079}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{6141602}-2231}{1079}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4462/1079)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{322,-366,-344\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 322, -366, -344\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $954$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(954 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-794$ is divisible by $27$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-794 % 27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3679}{3886}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{2957561}-3679}{7772}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3679/3886)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-508,458,650\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -508, 458, 650\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{15}$\n$x \\equiv 2 \\pmod{13}$\n$x \\equiv 7 \\pmod{17}$", + "Output Answer": [ + "$1809$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 15), (2, 13), (7, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 15), (2, 13), (7, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 15), (2, 13), (7, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $77393$.", + "Output Answer": [ + "$193^1\\cdot 401^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(77393))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.1432477_8$ to base 10.", + "Output Answer": [ + "$0.194$" + ], + "Output Program": [ + "n = '0.1432477'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $1153$.", + "Output Answer": [ + "$1153^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(1153))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1637x \\equiv 1 \\pmod{2439}$.", + "Output Answer": [ + "$1700$" + ], + "Output Program": [ + "print(pow(1637, -1, 2439))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $415^1293 \\pmod{1859}$.", + "Output Answer": [ + "$974$" + ], + "Output Program": [ + "print(pow(415, 1293, 1859))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1471x \\equiv 1 \\pmod{2137}$.", + "Output Answer": [ + "$369$" + ], + "Output Program": [ + "print(pow(1471, -1, 2137))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7351}{12846}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{714116065}-7351}{25692}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7351/12846)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $6$ is divisible by $-4$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(6 % -4 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 93819 \\pmod{59}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(93819 % 59)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46082)$.", + "Output Answer": [ + "$23040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46082))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n51841", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(51841))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $21^m \\equiv 1 \\pmod{766}$.", + "Output Answer": [ + "$191$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(21, 766))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{20389}{22152}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2378555737}-20389}{44304}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(20389/22152)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $53842$.", + "Output Answer": [ + "$\\{13,15,17,23,31,33,35,37,53,57\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(53842):\n if len(roots) == 10: break\n if gcd(a, 53842) == 1 and is_primitive_root(a, 53842):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{46,-139,-111\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 46, -139, -111\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-236,-319\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -236, -319\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40559)$.", + "Output Answer": [ + "$40558$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40559))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2138^1325 \\pmod{2364}$.", + "Output Answer": [ + "$932$" + ], + "Output Program": [ + "print(pow(2138, 1325, 2364))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-28574$ is divisible by $-26$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-28574 % -26 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $12115_6$ to base 10.", + "Output Answer": [ + "$1775$" + ], + "Output Program": [ + "n = '12115'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15217}{9334}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{580051313}-15217}{18668}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15217/9334)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27917)$.", + "Output Answer": [ + "$27916$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27917))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1012x \\equiv 1 \\pmod{1477}$.", + "Output Answer": [ + "$1423$" + ], + "Output Program": [ + "print(pow(1012, -1, 1477))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{22651}{5911}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{652827485}-22651}{11822}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22651/5911)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41857)$.", + "Output Answer": [ + "$39636$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41857))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 90333 \\pmod{39}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(90333 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n83607", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83607))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 81552 \\pmod{90}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "print(81552 % 90)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1231$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1231 % -41 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{12}$\n$x \\equiv 13 \\pmod{3}$\n$x \\equiv 13 \\pmod{13}$", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 12), (13, 3), (13, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 12), (13, 3), (13, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $4015$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(4015 % 25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2356^1670 \\pmod{2861}$.", + "Output Answer": [ + "$887$" + ], + "Output Program": [ + "print(pow(2356, 1670, 2861))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12542)$.", + "Output Answer": [ + "$6270$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12542))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1866$ to base $35$.", + "Output Answer": [ + "$\\text{1ib}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1866\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1097x \\equiv 1 \\pmod{2205}$.", + "Output Answer": [ + "$1403$" + ], + "Output Program": [ + "print(pow(1097, -1, 2205))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $2926$ is divisible by $11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2926 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2469}{6134}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{156599785}-2469}{12268}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2469/6134)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2443^2157 \\pmod{2733}$.", + "Output Answer": [ + "$1894$" + ], + "Output Program": [ + "print(pow(2443, 2157, 2733))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $546$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(546 % 25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $615x \\equiv 1 \\pmod{922}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(pow(615, -1, 922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21820 \\pmod{44}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(21820 % 44)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22028 \\pmod{78}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(22028 % 78)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1010^424 \\pmod{2917}$.", + "Output Answer": [ + "$811$" + ], + "Output Program": [ + "print(pow(1010, 424, 2917))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{524,-438,27\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 524, -438, 27\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 52717 \\pmod{16}$.", + "Output Answer": [ + "$13$" + ], + "Output Program": [ + "print(52717 % 16)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2224^149 \\pmod{2410}$.", + "Output Answer": [ + "$254$" + ], + "Output Program": [ + "print(pow(2224, 149, 2410))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n93325", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(93325))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 23713 \\pmod{89}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(23713 % 89)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27991)$.", + "Output Answer": [ + "$26752$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27991))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-370,-778\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -370, -778\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{416,867,-163\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 416, 867, -163\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $311x \\equiv 1 \\pmod{714}$.", + "Output Answer": [ + "$551$" + ], + "Output Program": [ + "print(pow(311, -1, 714))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $56713$.", + "Output Answer": [ + "$\\{5,7,11,13,14,15,20,21,22,26\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(56713):\n if len(roots) == 10: break\n if gcd(a, 56713) == 1 and is_primitive_root(a, 56713):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{768,737\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 768, 737\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $205x \\equiv 1 \\pmod{452}$.", + "Output Answer": [ + "$269$" + ], + "Output Program": [ + "print(pow(205, -1, 452))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41474)$.", + "Output Answer": [ + "$20416$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41474))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2441$ to base $21$.", + "Output Answer": [ + "$\\text{5b5}_{21}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 21\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2441\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $231^m \\equiv 1 \\pmod{481}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(231, 481))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $179x \\equiv 1 \\pmod{206}$.", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "print(pow(179, -1, 206))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $217^m \\equiv 1 \\pmod{530}$.", + "Output Answer": [ + "$52$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(217, 530))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1165^754 \\pmod{1643}$.", + "Output Answer": [ + "$1591$" + ], + "Output Program": [ + "print(pow(1165, 754, 1643))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-43240$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-43240 % -40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $450$ to base $2$.", + "Output Answer": [ + "$111000010_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 450\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-2665$ is divisible by $13$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-2665 % 13 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{7}$\n$x \\equiv 16 \\pmod{4}$\n$x \\equiv 11 \\pmod{17}$", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 7), (16, 4), (11, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 7), (16, 4), (11, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 7), (16, 4), (11, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-154,-683,681\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -154, -683, 681\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-58320$ is divisible by $40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-58320 % 40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $289^m \\equiv 1 \\pmod{324}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(289, 324))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{155,113\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 155, 113\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{13}$\n$x \\equiv 8 \\pmod{14}$\n$x \\equiv 6 \\pmod{18}$\n$x \\equiv 12 \\pmod{6}$", + "Output Answer": [ + "$1464$" + ], + "Output Program": [ + "constraints = (8, 13), (8, 14), (6, 18), (12, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 13), (8, 14), (6, 18), (12, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 19 \\pmod{11}$", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 5), (19, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (15, 5), (19, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (15, 5), (19, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $80678$.", + "Output Answer": [ + "$2^1\\cdot 13^1\\cdot 29^1\\cdot 107^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(80678))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{2}$\n$x \\equiv 10 \\pmod{12}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 2), (10, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 2), (10, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1172 \\pmod{72}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(1172 % 72)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $9^m \\equiv 1 \\pmod{170}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(9, 170))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1703^2162 \\pmod{1741}$.", + "Output Answer": [ + "$276$" + ], + "Output Program": [ + "print(pow(1703, 2162, 1741))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1377^2190 \\pmod{2506}$.", + "Output Answer": [ + "$2213$" + ], + "Output Program": [ + "print(pow(1377, 2190, 2506))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 1 \\pmod{14}$\n$x \\equiv 14 \\pmod{3}$", + "Output Answer": [ + "$659$" + ], + "Output Program": [ + "import math\n\nconstraints = (13, 19), (1, 14), (14, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (13, 19), (1, 14), (14, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (13, 19), (1, 14), (14, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1615^1122 \\pmod{2885}$.", + "Output Answer": [ + "$1720$" + ], + "Output Program": [ + "print(pow(1615, 1122, 2885))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 18 \\pmod{16}$", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "constraints = (19, 13), (18, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (19, 13), (18, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 13), (18, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{23161}{16519}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1627941365}-23161}{33038}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23161/16519)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{17}$\n$x \\equiv 9 \\pmod{19}$", + "Output Answer": [ + "$85$" + ], + "Output Program": [ + "import math\n\nconstraints = (0, 17), (9, 19)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 17), (9, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (0, 17), (9, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1844^201 \\pmod{1851}$.", + "Output Answer": [ + "$299$" + ], + "Output Program": [ + "print(pow(1844, 201, 1851))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $75x \\equiv 1 \\pmod{91}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(pow(75, -1, 91))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(2237)$.", + "Output Answer": [ + "$2236$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(2237))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $347x \\equiv 1 \\pmod{1799}$.", + "Output Answer": [ + "$534$" + ], + "Output Program": [ + "print(pow(347, -1, 1799))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63728 \\pmod{99}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(63728 % 99)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-946,-90\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -946, -90\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $20154$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 3359^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(20154))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1322^1156 \\pmod{1636}$.", + "Output Answer": [ + "$408$" + ], + "Output Program": [ + "print(pow(1322, 1156, 1636))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5740$ is divisible by $-25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(5740 % -25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{10}$\n$x \\equiv 14 \\pmod{13}$", + "Output Answer": [ + "$79$" + ], + "Output Program": [ + "import math\n\nconstraints = (19, 10), (14, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (19, 10), (14, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 10), (14, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{14346}{8663}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{126499498}-7173}{8663}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14346/8663)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $61^m \\equiv 1 \\pmod{238}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(61, 238))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $60443$.", + "Output Answer": [ + "$\\{2,5,6,8,11,13,14,15,18,19\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(60443):\n if len(roots) == 10: break\n if gcd(a, 60443) == 1 and is_primitive_root(a, 60443):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 16 \\pmod{15}$", + "Output Answer": [ + "$61$" + ], + "Output Program": [ + "constraints = (6, 11), (16, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 11), (16, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 11), (16, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2083$ to base $34$.", + "Output Answer": [ + "$\\text{1r9}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2083\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-823,-449\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -823, -449\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 18676 \\pmod{7}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(18676 % 7)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-990,559\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -990, 559\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2183^2307 \\pmod{2632}$.", + "Output Answer": [ + "$2575$" + ], + "Output Program": [ + "print(pow(2183, 2307, 2632))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{2}$\n$x \\equiv 11 \\pmod{3}$\n$x \\equiv 18 \\pmod{8}$", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "constraints = (14, 2), (11, 3), (18, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 2), (11, 3), (18, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1650$ is divisible by $-22$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1650 % -22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6810}{3359}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{22876906}-3405}{3359}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6810/3359)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{485}{16359}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1070702749}-485}{32718}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(485/16359)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{492,-566\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 492, -566\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{6}$\n$x \\equiv 17 \\pmod{2}$\n$x \\equiv 1 \\pmod{16}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "constraints = (17, 6), (17, 2), (1, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 6), (17, 2), (1, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{637,-747,436\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 637, -747, 436\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $99^m \\equiv 1 \\pmod{694}$.", + "Output Answer": [ + "$173$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(99, 694))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1202$ is divisible by $-42$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1202 % -42 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18686)$.", + "Output Answer": [ + "$9342$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18686))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{841,579\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 841, 579\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-812,731\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -812, 731\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48077 \\pmod{46}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(48077 % 46)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $19^m \\equiv 1 \\pmod{202}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(19, 202))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.424$ to base $14$.", + "Output Answer": [ + "$\\text{0.5d165}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.424\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $18837$ is divisible by $-39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18837 % -39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $105^m \\equiv 1 \\pmod{562}$.", + "Output Answer": [ + "$280$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(105, 562))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1203^642 \\pmod{1283}$.", + "Output Answer": [ + "$1203$" + ], + "Output Program": [ + "print(pow(1203, 642, 1283))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{8}$\n$x \\equiv 17 \\pmod{9}$", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 8), (17, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 8), (17, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 8), (17, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{13}$\n$x \\equiv 6 \\pmod{8}$\n$x \\equiv 16 \\pmod{18}$", + "Output Answer": [ + "$718$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 13), (6, 8), (16, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 13), (6, 8), (16, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $391x \\equiv 1 \\pmod{670}$.", + "Output Answer": [ + "$341$" + ], + "Output Program": [ + "print(pow(391, -1, 670))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-980,-97\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -980, -97\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1687x \\equiv 1 \\pmod{1782}$.", + "Output Answer": [ + "$619$" + ], + "Output Program": [ + "print(pow(1687, -1, 1782))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85178 \\pmod{48}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "print(85178 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21619 \\pmod{77}$.", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "print(21619 % 77)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $482^716 \\pmod{2375}$.", + "Output Answer": [ + "$1151$" + ], + "Output Program": [ + "print(pow(482, 716, 2375))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-278$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-278 % -21 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $851x \\equiv 1 \\pmod{1870}$.", + "Output Answer": [ + "$1191$" + ], + "Output Program": [ + "print(pow(851, -1, 1870))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $43885$.", + "Output Answer": [ + "$5^1\\cdot 67^1\\cdot 131^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(43885))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $430^537 \\pmod{2654}$.", + "Output Answer": [ + "$2132$" + ], + "Output Program": [ + "print(pow(430, 537, 2654))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 9 \\pmod{4}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "constraints = (9, 14), (9, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (9, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{7,839,647\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 7, 839, 647\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{22075}{17439}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1703780509}-22075}{34878}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(22075/17439)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1296$ to base $6$.", + "Output Answer": [ + "$10000_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1296\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1761^675 \\pmod{2770}$.", + "Output Answer": [ + "$2231$" + ], + "Output Program": [ + "print(pow(1761, 675, 2770))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1421x \\equiv 1 \\pmod{2210}$.", + "Output Answer": [ + "$1661$" + ], + "Output Program": [ + "print(pow(1421, -1, 2210))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3933}{28624}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3292801993}-3933}{57248}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3933/28624)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $935$ to base $24$.", + "Output Answer": [ + "$\\text{1en}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 935\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11623 \\pmod{78}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(11623 % 78)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $965^1542 \\pmod{2918}$.", + "Output Answer": [ + "$1927$" + ], + "Output Program": [ + "print(pow(965, 1542, 2918))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $268^439 \\pmod{985}$.", + "Output Answer": [ + "$907$" + ], + "Output Program": [ + "print(pow(268, 439, 985))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7107 \\pmod{28}$.", + "Output Answer": [ + "$23$" + ], + "Output Program": [ + "print(7107 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1739$ to base $32$.", + "Output Answer": [ + "$\\text{1mb}_{32}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 32\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1739\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $437x \\equiv 1 \\pmod{1129}$.", + "Output Answer": [ + "$1098$" + ], + "Output Program": [ + "print(pow(437, -1, 1129))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2402^571 \\pmod{2519}$.", + "Output Answer": [ + "$1720$" + ], + "Output Program": [ + "print(pow(2402, 571, 2519))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-10920$ is divisible by $-24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-10920 % -24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{5}$\n$x \\equiv 18 \\pmod{3}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 5), (18, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (14, 5), (18, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (14, 5), (18, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36225)$.", + "Output Answer": [ + "$15840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36225))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{16}$\n$x \\equiv 19 \\pmod{10}$", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 16), (19, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 16), (19, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2566$ to base $14$.", + "Output Answer": [ + "$\\text{d14}_{14}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 14\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2566\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{3}$\n$x \\equiv 13 \\pmod{19}$\n$x \\equiv 7 \\pmod{12}$\n$x \\equiv 8 \\pmod{17}$", + "Output Answer": [ + "$127$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (16, 3), (13, 19), (7, 12), (8, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (16, 3), (13, 19), (7, 12), (8, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $684x \\equiv 1 \\pmod{691}$.", + "Output Answer": [ + "$296$" + ], + "Output Program": [ + "print(pow(684, -1, 691))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-495,-487\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -495, -487\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{10272}{5453}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{56113705}-5136}{5453}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(10272/5453)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-443,-871\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -443, -871\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40876 \\pmod{46}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(40876 % 46)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(38423)$.", + "Output Answer": [ + "$29880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(38423))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{4}$\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 9 \\pmod{5}$", + "Output Answer": [ + "$29$" + ], + "Output Program": [ + "constraints = (9, 4), (11, 9), (9, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 4), (11, 9), (9, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 4), (11, 9), (9, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{17}$\n$x \\equiv 1 \\pmod{11}$\n$x \\equiv 13 \\pmod{6}$", + "Output Answer": [ + "$595$" + ], + "Output Program": [ + "constraints = (17, 17), (1, 11), (13, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 17), (1, 11), (13, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 17), (1, 11), (13, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $42866$.", + "Output Answer": [ + "$\\{5,7,15,21,23,31,43,45,63,69\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(42866):\n if len(roots) == 10: break\n if gcd(a, 42866) == 1 and is_primitive_root(a, 42866):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-992,-837,212\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -992, -837, 212\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2260^1638 \\pmod{2641}$.", + "Output Answer": [ + "$2566$" + ], + "Output Program": [ + "print(pow(2260, 1638, 2641))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3069}{929}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{514837}-3069}{1858}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3069/929)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39281)$.", + "Output Answer": [ + "$35700$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39281))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13827)$.", + "Output Answer": [ + "$8360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13827))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(48098)$.", + "Output Answer": [ + "$24048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(48098))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-2,4,2,-3\\}$.", + "Output Answer": [ + "$12$" + ], + "Output Program": [ + "import math\n\nvalues = -2, 4, 2, -3\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19558}{911}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{911} \\left(\\sqrt{96458762}-9779\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19558/911)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-34,21,79\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -34, 21, 79\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1495}{2189}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{21401909}-1495}{4378}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1495/2189)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-60$ is divisible by $-4$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-60 % -4 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n21617", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(21617))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9039}{56}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{112} \\left(\\sqrt{81716065}-9039\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9039/56)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1458$ to base $35$.", + "Output Answer": [ + "$\\text{16n}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1458\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75320 \\pmod{80}$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "print(75320 % 80)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88385 \\pmod{84}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(88385 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12520}{2699}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{46472201}-6260}{2699}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12520/2699)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3827}{5339}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{128665613}-3827}{10678}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3827/5339)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n3969", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(3969))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{23291}{16731}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{66487045}-23291}{33462}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23291/16731)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $68x \\equiv 1 \\pmod{483}$.", + "Output Answer": [ + "$206$" + ], + "Output Program": [ + "print(pow(68, -1, 483))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $74^m \\equiv 1 \\pmod{77}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(74, 77))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43519)$.", + "Output Answer": [ + "$37296$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43519))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1526$ is divisible by $-45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1526 % -45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1663x \\equiv 1 \\pmod{2114}$.", + "Output Answer": [ + "$2039$" + ], + "Output Program": [ + "print(pow(1663, -1, 2114))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $320^2481 \\pmod{2778}$.", + "Output Answer": [ + "$2300$" + ], + "Output Program": [ + "print(pow(320, 2481, 2778))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $287$ to base $3$.", + "Output Answer": [ + "$101122_3$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 3\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 287\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.186$ to base $8$.", + "Output Answer": [ + "$0.1371666_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.186\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $825x \\equiv 1 \\pmod{1108}$.", + "Output Answer": [ + "$877$" + ], + "Output Program": [ + "print(pow(825, -1, 1108))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{755,-888\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 755, -888\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $7^m \\equiv 1 \\pmod{136}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(7, 136))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $68^m \\equiv 1 \\pmod{163}$.", + "Output Answer": [ + "$162$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(68, 163))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{269}{205}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{410} \\left(\\sqrt{240461}-269\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(269/205)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33246)$.", + "Output Answer": [ + "$11076$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33246))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7755)$.", + "Output Answer": [ + "$3680$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7755))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $51838$.", + "Output Answer": [ + "$\\{11,17,33,37,41,51,53,55,61,71\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(51838):\n if len(roots) == 10: break\n if gcd(a, 51838) == 1 and is_primitive_root(a, 51838):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-611,-687\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -611, -687\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-305$ is divisible by $-8$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-305 % -8 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 27324 \\pmod{71}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "print(27324 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7768}{5443}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{44711705}-3884}{5443}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7768/5443)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{466,-873\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 466, -873\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3425)$.", + "Output Answer": [ + "$2720$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3425))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1324x \\equiv 1 \\pmod{2025}$.", + "Output Answer": [ + "$1999$" + ], + "Output Program": [ + "print(pow(1324, -1, 2025))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(3791)$.", + "Output Answer": [ + "$3552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(3791))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 92559 \\pmod{14}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(92559 % 14)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $197x \\equiv 1 \\pmod{448}$.", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "print(pow(197, -1, 448))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.241030303_5$ to base 10.", + "Output Answer": [ + "$0.569$" + ], + "Output Program": [ + "n = '0.241030303'.strip('.')\nbase = 5\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{151}{4080}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{66608401}-151}{8160}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(151/4080)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1001$ to base $24$.", + "Output Answer": [ + "$\\text{1hh}_{24}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 24\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1001\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-953,-558\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -953, -558\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-367,132,-469\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -367, 132, -469\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 32535 \\pmod{68}$.", + "Output Answer": [ + "$31$" + ], + "Output Program": [ + "print(32535 % 68)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $8x \\equiv 1 \\pmod{567}$.", + "Output Answer": [ + "$71$" + ], + "Output Program": [ + "print(pow(8, -1, 567))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{16167}{16552}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1357246705}-16167}{33104}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16167/16552)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $549x \\equiv 1 \\pmod{680}$.", + "Output Answer": [ + "$109$" + ], + "Output Program": [ + "print(pow(549, -1, 680))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{18}$\n$x \\equiv 10 \\pmod{2}$\n$x \\equiv 11 \\pmod{5}$", + "Output Answer": [ + "$76$" + ], + "Output Program": [ + "constraints = (4, 18), (10, 2), (11, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 18), (10, 2), (11, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 7 \\pmod{2}$\n$x \\equiv 11 \\pmod{2}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 5), (7, 2), (11, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 5), (7, 2), (11, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1836$ is divisible by $18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1836 % 18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-805,-684\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -805, -684\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2113}{2874}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{37504273}-2113}{5748}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2113/2874)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-91980$ is divisible by $45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-91980 % 45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 38372 \\pmod{7}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(38372 % 7)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $2017x \\equiv 1 \\pmod{2234}$.", + "Output Answer": [ + "$803$" + ], + "Output Program": [ + "print(pow(2017, -1, 2234))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{552,549,4\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 552, 549, 4\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1785^213 \\pmod{2504}$.", + "Output Answer": [ + "$1417$" + ], + "Output Program": [ + "print(pow(1785, 213, 2504))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $156^m \\equiv 1 \\pmod{337}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(156, 337))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-387$ is divisible by $19$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-387 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69014 \\pmod{96}$.", + "Output Answer": [ + "$86$" + ], + "Output Program": [ + "print(69014 % 96)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 75814 \\pmod{37}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(75814 % 37)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{19}$\n$x \\equiv 17 \\pmod{2}$\n$x \\equiv 11 \\pmod{17}$\n$x \\equiv 8 \\pmod{7}$", + "Output Answer": [ + "$2731$" + ], + "Output Program": [ + "import math\n\nconstraints = (14, 19), (17, 2), (11, 17), (8, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 19), (17, 2), (11, 17), (8, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 19), (17, 2), (11, 17), (8, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32067)$.", + "Output Answer": [ + "$18288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32067))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{97}{634}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1617233}-97}{1268}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(97/634)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41367)$.", + "Output Answer": [ + "$27576$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41367))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-327,-341\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -327, -341\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{647,318,205\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 647, 318, 205\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10860)$.", + "Output Answer": [ + "$2880$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10860))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $30983$.", + "Output Answer": [ + "$\\{5,7,10,14,15,21,23,28,29,30\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(30983):\n if len(roots) == 10: break\n if gcd(a, 30983) == 1 and is_primitive_root(a, 30983):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $766^135 \\pmod{1575}$.", + "Output Answer": [ + "$1126$" + ], + "Output Program": [ + "print(pow(766, 135, 1575))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{19135}{7421}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{586433189}-19135}{14842}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(19135/7421)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14222)$.", + "Output Answer": [ + "$6552$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14222))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n5713", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5713))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-4,3,0,0\\}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "import math\n\nvalues = -4, 3, 0, 0\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-476,603,69\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -476, 603, 69\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 21555 \\pmod{4}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(21555 % 4)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1550^468 \\pmod{2437}$.", + "Output Answer": [ + "$1966$" + ], + "Output Program": [ + "print(pow(1550, 468, 2437))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3545}{906}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{15850369}-3545}{1812}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3545/906)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1782^1383 \\pmod{2770}$.", + "Output Answer": [ + "$628$" + ], + "Output Program": [ + "print(pow(1782, 1383, 2770))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{19}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "constraints = (0, 19), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 19), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 19), (6, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $478^176 \\pmod{480}$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "print(pow(478, 176, 480))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $17551$.", + "Output Answer": [ + "$\\{3,6,7,14,15,17,23,24,33,35\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(17551):\n if len(roots) == 10: break\n if gcd(a, 17551) == 1 and is_primitive_root(a, 17551):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $327^m \\equiv 1 \\pmod{542}$.", + "Output Answer": [ + "$135$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(327, 542))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1512^780 \\pmod{1556}$.", + "Output Answer": [ + "$1248$" + ], + "Output Program": [ + "print(pow(1512, 780, 1556))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{9}$\n$x \\equiv 0 \\pmod{4}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nconstraints = (11, 9), (0, 4)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 9), (0, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 9), (0, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1763$ to base $34$.", + "Output Answer": [ + "$\\text{1ht}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1763\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $98^1933 \\pmod{385}$.", + "Output Answer": [ + "$98$" + ], + "Output Program": [ + "print(pow(98, 1933, 385))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-18$ is divisible by $1$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-18 % 1 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $485^1825 \\pmod{1178}$.", + "Output Answer": [ + "$129$" + ], + "Output Program": [ + "print(pow(485, 1825, 1178))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{18}$\n$x \\equiv 13 \\pmod{5}$\n$x \\equiv 18 \\pmod{4}$\n$x \\equiv 11 \\pmod{7}$", + "Output Answer": [ + "$158$" + ], + "Output Program": [ + "constraints = (14, 18), (13, 5), (18, 4), (11, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (14, 18), (13, 5), (18, 4), (11, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2018}{463}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{463} \\left(785 \\sqrt{2}-1009\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2018/463)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37050)$.", + "Output Answer": [ + "$8640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37050))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n101019", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(101019))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2067$ to base $6$.", + "Output Answer": [ + "$13323_6$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 6\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2067\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{780,-460\\}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "import math\n\nvalues = 780, -460\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $704$ is divisible by $11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(704 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $648^1017 \\pmod{2385}$.", + "Output Answer": [ + "$2088$" + ], + "Output Program": [ + "print(pow(648, 1017, 2385))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1382^1345 \\pmod{2603}$.", + "Output Answer": [ + "$2453$" + ], + "Output Program": [ + "print(pow(1382, 1345, 2603))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{186,36\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 186, 36\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{19}$\n$x \\equiv 7 \\pmod{14}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "import math\n\nconstraints = (11, 19), (7, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (11, 19), (7, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 19), (7, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $483^1682 \\pmod{2185}$.", + "Output Answer": [ + "$1679$" + ], + "Output Program": [ + "print(pow(483, 1682, 2185))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9134}{6551}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{63773090}-4567}{6551}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9134/6551)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(150)$.", + "Output Answer": [ + "$40$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(150))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n57465", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(57465))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-240$ is divisible by $-24$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-240 % -24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $167x \\equiv 1 \\pmod{1452}$.", + "Output Answer": [ + "$1139$" + ], + "Output Program": [ + "print(pow(167, -1, 1452))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{10}$\n$x \\equiv 17 \\pmod{18}$\n$x \\equiv 9 \\pmod{8}$\n$x \\equiv 10 \\pmod{17}$", + "Output Answer": [ + "$4481$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (11, 10), (17, 18), (9, 8), (10, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (11, 10), (17, 18), (9, 8), (10, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{8046}{1087}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{17366098}-4023}{1087}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(8046/1087)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(40588)$.", + "Output Answer": [ + "$19872$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(40588))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-86,-839\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -86, -839\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $646^897 \\pmod{1408}$.", + "Output Answer": [ + "$640$" + ], + "Output Program": [ + "print(pow(646, 897, 1408))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $489x \\equiv 1 \\pmod{626}$.", + "Output Answer": [ + "$297$" + ], + "Output Program": [ + "print(pow(489, -1, 626))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-43431$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-43431 % -31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $652x \\equiv 1 \\pmod{753}$.", + "Output Answer": [ + "$82$" + ], + "Output Program": [ + "print(pow(652, -1, 753))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(30955)$.", + "Output Answer": [ + "$24000$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(30955))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n9137", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9137))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $273^941 \\pmod{315}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(pow(273, 941, 315))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25497 \\pmod{63}$.", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "print(25497 % 63)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 6 \\pmod{6}$", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 3), (11, 11), (6, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 3), (11, 11), (6, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{14}$\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 10 \\pmod{17}$", + "Output Answer": [ + "$1676$" + ], + "Output Program": [ + "constraints = (10, 14), (12, 13), (10, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (10, 14), (12, 13), (10, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 14), (12, 13), (10, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 3 \\pmod{2}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 14), (3, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 14), (3, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n8999", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(8999))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1353^1469 \\pmod{1861}$.", + "Output Answer": [ + "$1375$" + ], + "Output Program": [ + "print(pow(1353, 1469, 1861))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-9666$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-9666 % -18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{402,-836\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 402, -836\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3157}{3525}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{59669149}-3157}{7050}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3157/3525)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{40884}{33235}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1522440589}-20442}{33235}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(40884/33235)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $321x \\equiv 1 \\pmod{1540}$.", + "Output Answer": [ + "$1161$" + ], + "Output Program": [ + "print(pow(321, -1, 1540))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{662,-31\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 662, -31\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2545}{6864}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{194935009}-2545}{13728}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2545/6864)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1514^2397 \\pmod{2387}$.", + "Output Answer": [ + "$743$" + ], + "Output Program": [ + "print(pow(1514, 2397, 2387))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $238^587 \\pmod{2792}$.", + "Output Answer": [ + "$1200$" + ], + "Output Program": [ + "print(pow(238, 587, 2792))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $139^m \\equiv 1 \\pmod{732}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(139, 732))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{5}$\n$x \\equiv 5 \\pmod{2}$\n$x \\equiv 9 \\pmod{16}$", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 5), (5, 2), (9, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 5), (5, 2), (9, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{13}$\n$x \\equiv 11 \\pmod{11}$\n$x \\equiv 9 \\pmod{12}$", + "Output Answer": [ + "$165$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 13), (11, 11), (9, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 13), (11, 11), (9, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (9, 13), (11, 11), (9, 12)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $405^1794 \\pmod{1717}$.", + "Output Answer": [ + "$910$" + ], + "Output Program": [ + "print(pow(405, 1794, 1717))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(47581)$.", + "Output Answer": [ + "$47580$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(47581))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{576,-662,365\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 576, -662, 365\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-8778$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-8778 % -14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97287 \\pmod{26}$.", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "print(97287 % 26)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1080$ is divisible by $8$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1080 % 8 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{784,-782,783\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 784, -782, 783\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $335^m \\equiv 1 \\pmod{651}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(335, 651))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{8}$\n$x \\equiv 9 \\pmod{14}$", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (9, 8), (9, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (9, 8), (9, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $7854$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(7854 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $159^m \\equiv 1 \\pmod{506}$.", + "Output Answer": [ + "$110$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(159, 506))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{7}$\n$x \\equiv 12 \\pmod{2}$", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 7), (12, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 7), (12, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (17, 7), (12, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{913,524,-537\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 913, 524, -537\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(44884)$.", + "Output Answer": [ + "$19152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(44884))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9716)$.", + "Output Answer": [ + "$4152$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9716))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{59}{183}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{366} \\left(\\sqrt{137437}-59\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(59/183)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 13 \\pmod{5}$", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "constraints = (0, 7), (13, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 7), (13, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (0, 7), (13, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17491}{12160}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{897397481}-17491}{24320}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17491/12160)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $480^1144 \\pmod{2656}$.", + "Output Answer": [ + "$1376$" + ], + "Output Program": [ + "print(pow(480, 1144, 2656))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $77x \\equiv 1 \\pmod{159}$.", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "print(pow(77, -1, 159))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $19902$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 31^1\\cdot 107^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(19902))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63581 \\pmod{21}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(63581 % 21)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1080$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1080 % -12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $300x \\equiv 1 \\pmod{1279}$.", + "Output Answer": [ + "$1198$" + ], + "Output Program": [ + "print(pow(300, -1, 1279))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{21340}{12961}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{281836421}-10670}{12961}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21340/12961)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n100297", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(100297))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $421$ is divisible by $-14$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(421 % -14 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{5}$\n$x \\equiv 6 \\pmod{11}$\n$x \\equiv 3 \\pmod{14}$", + "Output Answer": [ + "$633$" + ], + "Output Program": [ + "constraints = (8, 5), (6, 11), (3, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (8, 5), (6, 11), (3, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 5), (6, 11), (3, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-26078$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-26078 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{870,-135\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 870, -135\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 41345 \\pmod{39}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(41345 % 39)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-315$ is divisible by $-5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-315 % -5 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(15845)$.", + "Output Answer": [ + "$12672$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(15845))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $525^m \\equiv 1 \\pmod{709}$.", + "Output Answer": [ + "$177$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(525, 709))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $117^m \\equiv 1 \\pmod{590}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(117, 590))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $855^m \\equiv 1 \\pmod{883}$.", + "Output Answer": [ + "$441$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(855, 883))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2288^1517 \\pmod{2524}$.", + "Output Answer": [ + "$2284$" + ], + "Output Program": [ + "print(pow(2288, 1517, 2524))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $553x \\equiv 1 \\pmod{1860}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(pow(553, -1, 1860))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-953,31,60\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -953, 31, 60\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $16^m \\equiv 1 \\pmod{25}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(16, 25))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1253x \\equiv 1 \\pmod{1860}$.", + "Output Answer": [ + "$1097$" + ], + "Output Program": [ + "print(pow(1253, -1, 1860))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $41^2296 \\pmod{2974}$.", + "Output Answer": [ + "$2203$" + ], + "Output Program": [ + "print(pow(41, 2296, 2974))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35003)$.", + "Output Answer": [ + "$31360$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35003))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-580,-487\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -580, -487\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 63633 \\pmod{2}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(63633 % 2)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-725$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-725 % -17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(17724)$.", + "Output Answer": [ + "$5040$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(17724))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $281x \\equiv 1 \\pmod{684}$.", + "Output Answer": [ + "$185$" + ], + "Output Program": [ + "print(pow(281, -1, 684))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87367 \\pmod{24}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(87367 % 24)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $945$ is divisible by $-33$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(945 % -33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 11022 \\pmod{35}$.", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "print(11022 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $589^m \\equiv 1 \\pmod{642}$.", + "Output Answer": [ + "$106$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(589, 642))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{4}$\n$x \\equiv 16 \\pmod{11}$\n$x \\equiv 5 \\pmod{10}$", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "constraints = (1, 4), (16, 11), (5, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 4), (16, 11), (5, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9336}{6643}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{65919673}-4668}{6643}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9336/6643)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{451}{3336}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{44718985}-451}{6672}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(451/3336)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(33111)$.", + "Output Answer": [ + "$20304$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(33111))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{16184}{17473}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{370786193}-8092}{17473}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(16184/17473)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $29^m \\equiv 1 \\pmod{930}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(29, 930))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $576$ is divisible by $-41$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(576 % -41 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{18}$\n$x \\equiv 12 \\pmod{17}$", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 18), (12, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 18), (12, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 18), (12, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1660$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1660 % -38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1642^1138 \\pmod{1923}$.", + "Output Answer": [ + "$1534$" + ], + "Output Program": [ + "print(pow(1642, 1138, 1923))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-106,7,510\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -106, 7, 510\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-145,48,579\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -145, 48, 579\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1381$ to base $8$.", + "Output Answer": [ + "$2545_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1381\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $44579$.", + "Output Answer": [ + "$\\{2,6,8,10,13,14,17,18,19,22\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(44579):\n if len(roots) == 10: break\n if gcd(a, 44579) == 1 and is_primitive_root(a, 44579):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $96^m \\equiv 1 \\pmod{175}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(96, 175))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{11}$\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 20 \\pmod{10}$\n$x \\equiv 0 \\pmod{8}$", + "Output Answer": [ + "$120$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 11), (0, 2), (20, 10), (0, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 11), (0, 2), (20, 10), (0, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $168x \\equiv 1 \\pmod{1397}$.", + "Output Answer": [ + "$158$" + ], + "Output Program": [ + "print(pow(168, -1, 1397))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3312$ is divisible by $-12$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-3312 % -12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $113x \\equiv 1 \\pmod{676}$.", + "Output Answer": [ + "$341$" + ], + "Output Program": [ + "print(pow(113, -1, 676))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-83,853\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -83, 853\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{775,688\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 775, 688\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $222220_4$ to base 10.", + "Output Answer": [ + "$2728$" + ], + "Output Program": [ + "n = '222220'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $29x \\equiv 1 \\pmod{54}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "print(pow(29, -1, 54))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-449,-965\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -449, -965\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{9806}{1957}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{27869258}-4903}{1957}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(9806/1957)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-25353$ is divisible by $-27$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-25353 % -27 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $149^m \\equiv 1 \\pmod{462}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(149, 462))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2785$ to base $34$.", + "Output Answer": [ + "$\\text{2dv}_{34}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 34\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2785\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7954)$.", + "Output Answer": [ + "$3840$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1019^2063 \\pmod{2036}$.", + "Output Answer": [ + "$1019$" + ], + "Output Program": [ + "print(pow(1019, 2063, 2036))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $4x \\equiv 1 \\pmod{21}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(pow(4, -1, 21))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{15}$\n$x \\equiv 8 \\pmod{14}$\n$x \\equiv 18 \\pmod{8}$", + "Output Answer": [ + "$554$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 15), (8, 14), (18, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 15), (8, 14), (18, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(49315)$.", + "Output Answer": [ + "$33792$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(49315))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4655}{1283}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{28253381}-4655}{2566}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4655/1283)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17115}{18353}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1640253661}-17115}{36706}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17115/18353)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(32440)$.", + "Output Answer": [ + "$12960$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(32440))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{10}$\n$x \\equiv 0 \\pmod{4}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$260$" + ], + "Output Program": [ + "constraints = (10, 10), (0, 4), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (10, 10), (0, 4), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 0 \\pmod{17}$\n$x \\equiv 10 \\pmod{18}$\n$x \\equiv 2 \\pmod{10}$", + "Output Answer": [ + "$442$" + ], + "Output Program": [ + "constraints = (0, 17), (10, 18), (2, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (0, 17), (10, 18), (2, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-15655$ is divisible by $-31$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-15655 % -31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $756^1554 \\pmod{788}$.", + "Output Answer": [ + "$684$" + ], + "Output Program": [ + "print(pow(756, 1554, 788))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(39059)$.", + "Output Answer": [ + "$38640$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(39059))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 12 \\pmod{5}$\n$x \\equiv 2 \\pmod{2}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "constraints = (19, 13), (12, 5), (2, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (19, 13), (12, 5), (2, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (19, 13), (12, 5), (2, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 35211 \\pmod{73}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(35211 % 73)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{521}{194}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{388} \\left(\\sqrt{421985}-521\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(521/194)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{1,576,-308\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 1, 576, -308\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(27168)$.", + "Output Answer": [ + "$9024$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(27168))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $18810$ is divisible by $38$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18810 % 38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $109^m \\equiv 1 \\pmod{238}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(109, 238))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{11}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 9 \\pmod{14}$\n$x \\equiv 1 \\pmod{12}$", + "Output Answer": [ + "$205$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 11), (4, 3), (9, 14), (1, 12)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (7, 11), (4, 3), (9, 14), (1, 12)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1526$ is divisible by $-7$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-1526 % -7 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $341^m \\equiv 1 \\pmod{505}$.", + "Output Answer": [ + "$100$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(341, 505))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2806$ to base $25$.", + "Output Answer": [ + "$\\text{4c6}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2806\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(21369)$.", + "Output Answer": [ + "$13376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(21369))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{15}$\n$x \\equiv 5 \\pmod{17}$", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "import math\n\nconstraints = (6, 15), (5, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 15), (5, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (6, 15), (5, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 1 \\pmod{20}$", + "Output Answer": [ + "$141$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 19), (1, 20)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (8, 19), (1, 20)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 19), (1, 20)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $978^74 \\pmod{1868}$.", + "Output Answer": [ + "$852$" + ], + "Output Program": [ + "print(pow(978, 74, 1868))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 19 \\pmod{2}$\n$x \\equiv 9 \\pmod{5}$", + "Output Answer": [ + "$59$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 11), (19, 2), (9, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 11), (19, 2), (9, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 11), (19, 2), (9, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $600^297 \\pmod{2449}$.", + "Output Answer": [ + "$387$" + ], + "Output Program": [ + "print(pow(600, 297, 2449))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $86920$.", + "Output Answer": [ + "$2^3\\cdot 5^1\\cdot 41^1\\cdot 53^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(86920))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 88352 \\pmod{81}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "print(88352 % 81)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50087 \\pmod{31}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "print(50087 % 31)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{29486}{6163}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{255338618}-14743}{6163}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(29486/6163)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1290x \\equiv 1 \\pmod{1663}$.", + "Output Answer": [ + "$107$" + ], + "Output Program": [ + "print(pow(1290, -1, 1663))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $605x \\equiv 1 \\pmod{1296}$.", + "Output Answer": [ + "$437$" + ], + "Output Program": [ + "print(pow(605, -1, 1296))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{27417}{14084}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1545128113}-27417}{28168}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(27417/14084)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{8}$\n$x \\equiv 2 \\pmod{5}$\n$x \\equiv 5 \\pmod{18}$", + "Output Answer": [ + "$257$" + ], + "Output Program": [ + "constraints = (17, 8), (2, 5), (5, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 8), (2, 5), (5, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $2120$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2120 % -40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{593,226\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 593, 226\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n62383", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(62383))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54838 \\pmod{44}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(54838 % 44)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1299}{10898}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{476753017}-1299}{21796}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1299/10898)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $5783$.", + "Output Answer": [ + "$\\{7,10,15,17,19,20,21,26,28,29\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(5783):\n if len(roots) == 10: break\n if gcd(a, 5783) == 1 and is_primitive_root(a, 5783):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $84$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(84 % 48 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{26614}{7981}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{13 \\sqrt{1424690}-13307}{7981}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(26614/7981)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{13}$\n$x \\equiv 6 \\pmod{3}$\n$x \\equiv 10 \\pmod{16}$", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 13), (6, 3), (10, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 13), (6, 3), (10, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (12, 13), (6, 3), (10, 16)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-274$ is divisible by $-30$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-274 % -30 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $476^606 \\pmod{2878}$.", + "Output Answer": [ + "$1710$" + ], + "Output Program": [ + "print(pow(476, 606, 2878))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-1310$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-1310 % 28 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $154_8$ to base 10.", + "Output Answer": [ + "$108$" + ], + "Output Program": [ + "n = '154'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1500^1643 \\pmod{2455}$.", + "Output Answer": [ + "$2140$" + ], + "Output Program": [ + "print(pow(1500, 1643, 2455))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14907)$.", + "Output Answer": [ + "$9936$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14907))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{316,-590\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 316, -590\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{17}$\n$x \\equiv 11 \\pmod{15}$\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 11 \\pmod{4}$", + "Output Answer": [ + "$491$" + ], + "Output Program": [ + "constraints = (15, 17), (11, 15), (15, 2), (11, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 17), (11, 15), (15, 2), (11, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $553x \\equiv 1 \\pmod{1782}$.", + "Output Answer": [ + "$1753$" + ], + "Output Program": [ + "print(pow(553, -1, 1782))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-288,-798\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = -288, -798\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n12977", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(12977))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17969 \\pmod{87}$.", + "Output Answer": [ + "$47$" + ], + "Output Program": [ + "print(17969 % 87)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5287}{5284}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{139634993}-5287}{10568}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5287/5284)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $184x \\equiv 1 \\pmod{753}$.", + "Output Answer": [ + "$487$" + ], + "Output Program": [ + "print(pow(184, -1, 753))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31006)$.", + "Output Answer": [ + "$15048$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31006))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1709}{680}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4770281}-1709}{1360}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1709/680)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{2}$\n$x \\equiv 2 \\pmod{17}$\n$x \\equiv 3 \\pmod{3}$\n$x \\equiv 9 \\pmod{9}$", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 2), (2, 17), (3, 3), (9, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (4, 2), (2, 17), (3, 3), (9, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n58311", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(58311))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $26^826 \\pmod{3000}$.", + "Output Answer": [ + "$2776$" + ], + "Output Program": [ + "print(pow(26, 826, 3000))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 17 \\pmod{19}$\n$x \\equiv 1 \\pmod{9}$\n$x \\equiv 6 \\pmod{16}$", + "Output Answer": [ + "$2278$" + ], + "Output Program": [ + "constraints = (18, 10), (17, 19), (1, 9), (6, 16)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 10), (17, 19), (1, 9), (6, 16)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18242)$.", + "Output Answer": [ + "$7812$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18242))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{849,-596\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 849, -596\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $52466$.", + "Output Answer": [ + "$2^1\\cdot 37^1\\cdot 709^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(52466))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1776 \\pmod{82}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "print(1776 % 82)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $143^m \\equiv 1 \\pmod{647}$.", + "Output Answer": [ + "$646$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(143, 647))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1801^452 \\pmod{1984}$.", + "Output Answer": [ + "$1249$" + ], + "Output Program": [ + "print(pow(1801, 452, 1984))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $117^m \\equiv 1 \\pmod{473}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(117, 473))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49884 \\pmod{83}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(49884 % 83)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4406}{4735}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{27273434}-2203}{4735}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4406/4735)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 19999 \\pmod{17}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(19999 % 17)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-848$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-848 % -17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $8578$.", + "Output Answer": [ + "$\\{3,7,11,15,17,19,23,27,29,31\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(8578):\n if len(roots) == 10: break\n if gcd(a, 8578) == 1 and is_primitive_root(a, 8578):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 6 \\pmod{7}$\n$x \\equiv 0 \\pmod{15}$", + "Output Answer": [ + "$90$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (6, 7), (0, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (6, 7), (0, 15)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (6, 7), (0, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1828$ to base $19$.", + "Output Answer": [ + "$514_{19}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 19\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1828\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $31^m \\equiv 1 \\pmod{624}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(31, 624))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $775x \\equiv 1 \\pmod{1016}$.", + "Output Answer": [ + "$215$" + ], + "Output Program": [ + "print(pow(775, -1, 1016))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{32366}{5179}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{288711530}-16183}{5179}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(32366/5179)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4622}{6689}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{50083442}-2311}{6689}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4622/6689)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $209x \\equiv 1 \\pmod{2132}$.", + "Output Answer": [ + "$2081$" + ], + "Output Program": [ + "print(pow(209, -1, 2132))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n65121", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(65121))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $343^m \\equiv 1 \\pmod{474}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(343, 474))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n63073", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(63073))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{190,497\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 190, 497\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $139x \\equiv 1 \\pmod{1125}$.", + "Output Answer": [ + "$259$" + ], + "Output Program": [ + "print(pow(139, -1, 1125))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14336)$.", + "Output Answer": [ + "$6144$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14336))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $13503$ is divisible by $-21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(13503 % -21 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1232^1303 \\pmod{2954}$.", + "Output Answer": [ + "$1232$" + ], + "Output Program": [ + "print(pow(1232, 1303, 2954))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $11^m \\equiv 1 \\pmod{222}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(11, 222))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $266^m \\equiv 1 \\pmod{327}$.", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(266, 327))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17272 \\pmod{9}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(17272 % 9)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the least common multiple of $\\{-1,1,-5\\}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "import math\n\nvalues = -1, 1, -5\nprint(math.lcm(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $5263_7$ to base 10.", + "Output Answer": [ + "$1858$" + ], + "Output Program": [ + "n = '5263'.strip('.')\nbase = 7\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1297^1718 \\pmod{2770}$.", + "Output Answer": [ + "$1539$" + ], + "Output Program": [ + "print(pow(1297, 1718, 2770))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $21727$.", + "Output Answer": [ + "$\\{3,5,6,10,12,20,21,24,33,37\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(21727):\n if len(roots) == 10: break\n if gcd(a, 21727) == 1 and is_primitive_root(a, 21727):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $307^m \\equiv 1 \\pmod{888}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(307, 888))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{20}$\n$x \\equiv 7 \\pmod{5}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (7, 20), (7, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 20), (7, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{18}$\n$x \\equiv 18 \\pmod{13}$\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 18 \\pmod{15}$", + "Output Answer": [ + "$1578$" + ], + "Output Program": [ + "constraints = (12, 18), (18, 13), (2, 4), (18, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (12, 18), (18, 13), (2, 4), (18, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $75x \\equiv 1 \\pmod{196}$.", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "print(pow(75, -1, 196))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $18124$ is divisible by $-23$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(18124 % -23 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(43308)$.", + "Output Answer": [ + "$14400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(43308))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $35^m \\equiv 1 \\pmod{57}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(35, 57))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{5}$\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 5 \\pmod{7}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (4, 5), (0, 2), (5, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (4, 5), (0, 2), (5, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 5), (0, 2), (5, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-847$ is divisible by $22$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-847 % 22 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 37173 \\pmod{37}$.", + "Output Answer": [ + "$25$" + ], + "Output Program": [ + "print(37173 % 37)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 40546 \\pmod{41}$.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "print(40546 % 41)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{18157}{19379}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1831859213}-18157}{38758}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(18157/19379)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1090x \\equiv 1 \\pmod{2469}$.", + "Output Answer": [ + "$1384$" + ], + "Output Program": [ + "print(pow(1090, -1, 2469))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$114$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 13), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (10, 13), (6, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (10, 13), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{561}{2633}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{28045477}-561}{5266}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(561/2633)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{7,15,-892\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 7, 15, -892\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $632^m \\equiv 1 \\pmod{927}$.", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(632, 927))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2427^2097 \\pmod{2858}$.", + "Output Answer": [ + "$2137$" + ], + "Output Program": [ + "print(pow(2427, 2097, 2858))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-139$ is divisible by $-15$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-139 % -15 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $924$ is divisible by $24$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(924 % 24 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1084 \\pmod{44}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "print(1084 % 44)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $11973$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(11973 % 39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-598,-805\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -598, -805\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n92239", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(92239))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 81036 \\pmod{51}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(81036 % 51)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5481}{461}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{922} \\left(\\sqrt{30891445}-5481\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5481/461)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{315,755,-508\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 315, 755, -508\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1149^329 \\pmod{2354}$.", + "Output Answer": [ + "$1813$" + ], + "Output Program": [ + "print(pow(1149, 329, 2354))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\n\nDetermine the $n=7$ $10$-gonal number.\n", + "Output Answer": [ + "$235$" + ], + "Output Program": [ + "n = 7\nk = 10\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $332^2432 \\pmod{2233}$.", + "Output Answer": [ + "$268$" + ], + "Output Program": [ + "print(pow(332, 2432, 2233))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{13933}{29512}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{3677961065}-13933}{59024}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(13933/29512)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $913^m \\equiv 1 \\pmod{922}$.", + "Output Answer": [ + "$115$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(913, 922))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n7255", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7255))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1526_8$ to base 10.", + "Output Answer": [ + "$854$" + ], + "Output Program": [ + "n = '1526'.strip('.')\nbase = 8\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $25^m \\equiv 1 \\pmod{234}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(25, 234))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $199x \\equiv 1 \\pmod{674}$.", + "Output Answer": [ + "$105$" + ], + "Output Program": [ + "print(pow(199, -1, 674))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1991^1881 \\pmod{2318}$.", + "Output Answer": [ + "$1101$" + ], + "Output Program": [ + "print(pow(1991, 1881, 2318))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 19 \\pmod{13}$\n$x \\equiv 3 \\pmod{14}$\n$x \\equiv 3 \\pmod{3}$", + "Output Answer": [ + "$45$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (19, 13), (3, 14), (3, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (19, 13), (3, 14), (3, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (19, 13), (3, 14), (3, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70640 \\pmod{35}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(70640 % 35)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $88^1037 \\pmod{580}$.", + "Output Answer": [ + "$88$" + ], + "Output Program": [ + "print(pow(88, 1037, 580))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $31651$.", + "Output Answer": [ + "$31^1\\cdot 1021^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(31651))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 16 \\pmod{2}$", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "constraints = (11, 7), (16, 2)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (11, 7), (16, 2)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (16, 2)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $65^m \\equiv 1 \\pmod{948}$.", + "Output Answer": [ + "$26$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(65, 948))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1460}{18201}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{331809301}-730}{18201}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1460/18201)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{19}$\n$x \\equiv 0 \\pmod{14}$\n$x \\equiv 0 \\pmod{7}$\n$x \\equiv 19 \\pmod{15}$", + "Output Answer": [ + "$1624$" + ], + "Output Program": [ + "constraints = (9, 19), (0, 14), (0, 7), (19, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 19), (0, 14), (0, 7), (19, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{5}$\n$x \\equiv 10 \\pmod{13}$\n$x \\equiv 13 \\pmod{17}$", + "Output Answer": [ + "$1050$" + ], + "Output Program": [ + "import math\n\nconstraints = (20, 5), (10, 13), (13, 17)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (20, 5), (10, 13), (13, 17)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (20, 5), (10, 13), (13, 17)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{694}{575}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{575} \\left(\\sqrt{451034}-347\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(694/575)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $657x \\equiv 1 \\pmod{673}$.", + "Output Answer": [ + "$42$" + ], + "Output Program": [ + "print(pow(657, -1, 673))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-494,191\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -494, 191\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $953^415 \\pmod{1299}$.", + "Output Answer": [ + "$746$" + ], + "Output Program": [ + "print(pow(953, 415, 1299))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $70601$.", + "Output Answer": [ + "$17^1\\cdot 4153^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(70601))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2740}{8097}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{37 \\sqrt{49261}-1370}{8097}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2740/8097)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45200)$.", + "Output Answer": [ + "$17920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45200))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $173x \\equiv 1 \\pmod{290}$.", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "print(pow(173, -1, 290))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{152,-491,-371\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 152, -491, -371\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 97658 \\pmod{37}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(97658 % 37)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13703)$.", + "Output Answer": [ + "$13440$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13703))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $175^332 \\pmod{2380}$.", + "Output Answer": [ + "$1925$" + ], + "Output Program": [ + "print(pow(175, 332, 2380))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{15995}{23236}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2415486809}-15995}{46472}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(15995/23236)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $88x \\equiv 1 \\pmod{105}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(pow(88, -1, 105))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 86754 \\pmod{58}$.", + "Output Answer": [ + "$44$" + ], + "Output Program": [ + "print(86754 % 58)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-956,857,-336\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -956, 857, -336\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 20 \\pmod{7}$\n$x \\equiv 12 \\pmod{17}$\n$x \\equiv 11 \\pmod{6}$", + "Output Answer": [ + "$1763$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 19), (20, 7), (12, 17), (11, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 19), (20, 7), (12, 17), (11, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 19), (20, 7), (12, 17), (11, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 9 \\pmod{9}$\n$x \\equiv 14 \\pmod{8}$", + "Output Answer": [ + "$54$" + ], + "Output Program": [ + "import math\n\nconstraints = (9, 9), (14, 8)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (9, 9), (14, 8)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (9, 9), (14, 8)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{5}$\n$x \\equiv 20 \\pmod{14}$", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (15, 5), (20, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 5), (20, 14)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (15, 5), (20, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{829,-483\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 829, -483\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2101}{3330}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{48769801}-2101}{6660}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2101/3330)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $13781$.", + "Output Answer": [ + "$\\{7,10,15,17,22,28,31,33,35,38\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(13781):\n if len(roots) == 10: break\n if gcd(a, 13781) == 1 and is_primitive_root(a, 13781):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 12 \\pmod{10}$\n$x \\equiv 0 \\pmod{19}$\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 19 \\pmod{9}$", + "Output Answer": [ + "$532$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (12, 10), (0, 19), (7, 3), (19, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (12, 10), (0, 19), (7, 3), (19, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{12}$\n$x \\equiv 5 \\pmod{15}$\n$x \\equiv 18 \\pmod{19}$", + "Output Answer": [ + "$170$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 12), (5, 15), (18, 19)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 12), (5, 15), (18, 19)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1896^704 \\pmod{2006}$.", + "Output Answer": [ + "$1038$" + ], + "Output Program": [ + "print(pow(1896, 704, 2006))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-227,270\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -227, 270\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.138$ to base $25$.", + "Output Answer": [ + "$\\text{0.3b66}_{25}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 25\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.138\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $32445$ is divisible by $45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(32445 % 45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{21770}{19307}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{491243474}-10885}{19307}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(21770/19307)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-388,-404\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -388, -404\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{55}{139}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{278} \\left(\\sqrt{80309}-55\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(55/139)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{20}$\n$x \\equiv 3 \\pmod{9}$", + "Output Answer": [ + "$102$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 20), (3, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 20), (3, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (2, 20), (3, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9106)$.", + "Output Answer": [ + "$4368$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9106))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-698$ is divisible by $-16$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-698 % -16 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $21321_6$ to base 10.", + "Output Answer": [ + "$2929$" + ], + "Output Program": [ + "n = '21321'.strip('.')\nbase = 6\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $163x \\equiv 1 \\pmod{903}$.", + "Output Answer": [ + "$277$" + ], + "Output Program": [ + "print(pow(163, -1, 903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16724)$.", + "Output Answer": [ + "$8064$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16724))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $22^m \\equiv 1 \\pmod{169}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(22, 169))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-966,-940\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = -966, -940\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $187x \\equiv 1 \\pmod{641}$.", + "Output Answer": [ + "$24$" + ], + "Output Program": [ + "print(pow(187, -1, 641))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 17193 \\pmod{88}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(17193 % 88)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2659}{1908}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{21632137}-2659}{3816}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2659/1908)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2726}{16819}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{284736530}-1363}{16819}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2726/16819)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6284}{6459}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{51590845}-3142}{6459}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6284/6459)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 31659 \\pmod{32}$.", + "Output Answer": [ + "$11$" + ], + "Output Program": [ + "print(31659 % 32)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16048)$.", + "Output Answer": [ + "$7424$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16048))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $367$ is divisible by $31$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(367 % 31 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{874,710\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 874, 710\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-163,-362\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -163, -362\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1549x \\equiv 1 \\pmod{1560}$.", + "Output Answer": [ + "$709$" + ], + "Output Program": [ + "print(pow(1549, -1, 1560))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(7265)$.", + "Output Answer": [ + "$5808$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(7265))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1278^508 \\pmod{2989}$.", + "Output Answer": [ + "$2657$" + ], + "Output Program": [ + "print(pow(1278, 508, 2989))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $123x \\equiv 1 \\pmod{2495}$.", + "Output Answer": [ + "$142$" + ], + "Output Program": [ + "print(pow(123, -1, 2495))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 73293 \\pmod{69}$.", + "Output Answer": [ + "$15$" + ], + "Output Program": [ + "print(73293 % 69)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n9187", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(9187))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $230$ is divisible by $-5$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(230 % -5 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2341^201 \\pmod{2903}$.", + "Output Answer": [ + "$2296$" + ], + "Output Program": [ + "print(pow(2341, 201, 2903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(45298)$.", + "Output Answer": [ + "$19600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(45298))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{255,-687\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 255, -687\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $149^2045 \\pmod{2642}$.", + "Output Answer": [ + "$1353$" + ], + "Output Program": [ + "print(pow(149, 2045, 2642))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2124^159 \\pmod{2815}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "print(pow(2124, 159, 2815))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{8}$\n$x \\equiv 14 \\pmod{3}$\n$x \\equiv 5 \\pmod{9}$", + "Output Answer": [ + "$32$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (8, 8), (14, 3), (5, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 8), (14, 3), (5, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1847x \\equiv 1 \\pmod{2175}$.", + "Output Answer": [ + "$683$" + ], + "Output Program": [ + "print(pow(1847, -1, 2175))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{34970}{14687}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{521433194}-17485}{14687}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(34970/14687)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(6903)$.", + "Output Answer": [ + "$4176$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(6903))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $289^m \\equiv 1 \\pmod{312}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(289, 312))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-99,157,-761\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -99, 157, -761\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1856^1628 \\pmod{1993}$.", + "Output Answer": [ + "$1895$" + ], + "Output Program": [ + "print(pow(1856, 1628, 1993))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29548)$.", + "Output Answer": [ + "$14432$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29548))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $875^m \\equiv 1 \\pmod{946}$.", + "Output Answer": [ + "$210$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(875, 946))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $272$ is divisible by $-17$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(272 % -17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{305,3\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 305, 3\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 2136 \\pmod{42}$.", + "Output Answer": [ + "$36$" + ], + "Output Program": [ + "print(2136 % 42)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $273x \\equiv 1 \\pmod{340}$.", + "Output Answer": [ + "$137$" + ], + "Output Program": [ + "print(pow(273, -1, 340))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(46057)$.", + "Output Answer": [ + "$40560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(46057))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $285^m \\equiv 1 \\pmod{299}$.", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(285, 299))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{14845}{581}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{221724269}-14845}{1162}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14845/581)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{235,748,-686\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 235, 748, -686\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n31569", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(31569))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{12993}{6590}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{342530449}-12993}{13180}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(12993/6590)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{14491}{8346}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{488611945}-14491}{16692}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(14491/8346)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-917,506\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -917, 506\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $2584$ is divisible by $19$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(2584 % 19 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1338^1313 \\pmod{2570}$.", + "Output Answer": [ + "$308$" + ], + "Output Program": [ + "print(pow(1338, 1313, 2570))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31216)$.", + "Output Answer": [ + "$15600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31216))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1201x \\equiv 1 \\pmod{1459}$.", + "Output Answer": [ + "$1295$" + ], + "Output Program": [ + "print(pow(1201, -1, 1459))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 39444 \\pmod{22}$.", + "Output Answer": [ + "$20$" + ], + "Output Program": [ + "print(39444 % 22)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(14925)$.", + "Output Answer": [ + "$7920$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(14925))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{6519}{2113}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{60356437}-6519}{4226}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(6519/2113)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1990^1776 \\pmod{2508}$.", + "Output Answer": [ + "$1816$" + ], + "Output Program": [ + "print(pow(1990, 1776, 2508))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3092}{8891}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{81439997}-1546}{8891}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3092/8891)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{16}$\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 4 \\pmod{13}$", + "Output Answer": [ + "$147$" + ], + "Output Program": [ + "import math\n\nconstraints = (3, 16), (15, 3), (4, 13)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (3, 16), (15, 3), (4, 13)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 16), (15, 3), (4, 13)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 10670 \\pmod{96}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "print(10670 % 96)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1982}{317}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{317} \\left(\\sqrt{1082570}-991\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1982/317)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $4^m \\equiv 1 \\pmod{259}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(4, 259))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{7}$\n$x \\equiv 17 \\pmod{10}$", + "Output Answer": [ + "$57$" + ], + "Output Program": [ + "import math\n\nconstraints = (1, 7), (17, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (1, 7), (17, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (1, 7), (17, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(16233)$.", + "Output Answer": [ + "$9264$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(16233))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(34305)$.", + "Output Answer": [ + "$18288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(34305))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 46842 \\pmod{71}$.", + "Output Answer": [ + "$53$" + ], + "Output Program": [ + "print(46842 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 84455 \\pmod{32}$.", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "print(84455 % 32)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 11 \\pmod{7}$\n$x \\equiv 8 \\pmod{10}$", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "constraints = (11, 7), (8, 10)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (11, 7), (8, 10)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (11, 7), (8, 10)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12819)$.", + "Output Answer": [ + "$8544$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12819))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{680,-638\\}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "import math\n\nvalues = 680, -638\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10990)$.", + "Output Answer": [ + "$3744$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10990))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-44286$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-44286 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n6369", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(6369))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{158,-493\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 158, -493\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $481^m \\equiv 1 \\pmod{976}$.", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(481, 976))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $37708$.", + "Output Answer": [ + "$2^2\\cdot 11^1\\cdot 857^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(37708))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $648$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(648 % -18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-273,509,-302\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -273, 509, -302\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1329$ to base $35$.", + "Output Answer": [ + "$\\text{12y}_{35}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 35\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 1329\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 4 \\pmod{7}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$60$" + ], + "Output Program": [ + "import math\n\nconstraints = (4, 7), (6, 18)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (4, 7), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (4, 7), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 43361 \\pmod{6}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(43361 % 6)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1446$ is divisible by $6$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(1446 % 6 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $117x \\equiv 1 \\pmod{1870}$.", + "Output Answer": [ + "$943$" + ], + "Output Program": [ + "print(pow(117, -1, 1870))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n96337", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(96337))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n90497", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(90497))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{7705}{17596}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1297843889}-7705}{35192}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(7705/17596)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 10 \\pmod{7}$\n$x \\equiv 16 \\pmod{10}$\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 19 \\pmod{3}$", + "Output Answer": [ + "$976$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (10, 7), (16, 10), (8, 11), (19, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (10, 7), (16, 10), (8, 11), (19, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (10, 7), (16, 10), (8, 11), (19, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-21373$ is divisible by $29$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-21373 % 29 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-654,364\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -654, 364\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 79050 \\pmod{52}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "print(79050 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48936 \\pmod{84}$.", + "Output Answer": [ + "$48$" + ], + "Output Program": [ + "print(48936 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 14 \\pmod{11}$\n$x \\equiv 8 \\pmod{19}$\n$x \\equiv 5 \\pmod{4}$\n$x \\equiv 17 \\pmod{18}$", + "Output Answer": [ + "$3941$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (14, 11), (8, 19), (5, 4), (17, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (14, 11), (8, 19), (5, 4), (17, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{40,35,-623\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 40, 35, -623\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2514}{5101}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1104010}-1257}{5101}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2514/5101)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2384$ to base $28$.", + "Output Answer": [ + "$314_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2384\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.064$ to base $28$.", + "Output Answer": [ + "$\\text{0.1m4q}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.064\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-57708$ is divisible by $36$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-57708 % 36 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $106_{17}$ to base 10.", + "Output Answer": [ + "$295$" + ], + "Output Program": [ + "n = '106'.strip('.')\nbase = 17\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $787x \\equiv 1 \\pmod{1390}$.", + "Output Answer": [ + "$763$" + ], + "Output Program": [ + "print(pow(787, -1, 1390))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $157^m \\equiv 1 \\pmod{707}$.", + "Output Answer": [ + "$150$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(157, 707))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $111^m \\equiv 1 \\pmod{166}$.", + "Output Answer": [ + "$41$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(111, 166))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $604$ is divisible by $17$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(604 % 17 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1719^1172 \\pmod{2810}$.", + "Output Answer": [ + "$1641$" + ], + "Output Program": [ + "print(pow(1719, 1172, 2810))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $466^285 \\pmod{2135}$.", + "Output Answer": [ + "$1646$" + ], + "Output Program": [ + "print(pow(466, 285, 2135))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $95x \\equiv 1 \\pmod{659}$.", + "Output Answer": [ + "$111$" + ], + "Output Program": [ + "print(pow(95, -1, 659))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{227,-25,480\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 227, -25, 480\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $757x \\equiv 1 \\pmod{2310}$.", + "Output Answer": [ + "$1303$" + ], + "Output Program": [ + "print(pow(757, -1, 2310))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(41825)$.", + "Output Answer": [ + "$28560$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(41825))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11582)$.", + "Output Answer": [ + "$5790$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11582))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{386,550,17\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 386, 550, 17\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 25121 \\pmod{85}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "print(25121 % 85)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{480,197\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 480, 197\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1016^520 \\pmod{2333}$.", + "Output Answer": [ + "$1746$" + ], + "Output Program": [ + "print(pow(1016, 520, 2333))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-319,677,-730\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -319, 677, -730\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 13 \\pmod{18}$\n$x \\equiv 9 \\pmod{5}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 1 \\pmod{3}$", + "Output Answer": [ + "$49$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (13, 18), (9, 5), (4, 3), (1, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (13, 18), (9, 5), (4, 3), (1, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{683,834\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 683, 834\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 29031 \\pmod{71}$.", + "Output Answer": [ + "$63$" + ], + "Output Program": [ + "print(29031 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $467^m \\equiv 1 \\pmod{739}$.", + "Output Answer": [ + "$738$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(467, 739))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5907$ is divisible by $11$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5907 % 11 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{261,-580,121\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 261, -580, 121\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{183,444,-814\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 183, 444, -814\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-28070$ is divisible by $35$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-28070 % 35 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $111x \\equiv 1 \\pmod{604}$.", + "Output Answer": [ + "$419$" + ], + "Output Program": [ + "print(pow(111, -1, 604))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $11592$ is divisible by $48$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(11592 % 48 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1022^2126 \\pmod{2045}$.", + "Output Answer": [ + "$1949$" + ], + "Output Program": [ + "print(pow(1022, 2126, 2045))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $44392$.", + "Output Answer": [ + "$2^3\\cdot 31^1\\cdot 179^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(44392))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.808$ to base $8$.", + "Output Answer": [ + "$0.6355443_8$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 8\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.808\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{511,-976,400\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 511, -976, 400\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n83069", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(83069))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $517^m \\equiv 1 \\pmod{831}$.", + "Output Answer": [ + "$92$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(517, 831))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-877,12,-61\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -877, 12, -61\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 72703 \\pmod{19}$.", + "Output Answer": [ + "$9$" + ], + "Output Program": [ + "print(72703 % 19)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1543x \\equiv 1 \\pmod{2490}$.", + "Output Answer": [ + "$1057$" + ], + "Output Program": [ + "print(pow(1543, -1, 2490))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3628}{9905}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{101399621}-1814}{9905}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3628/9905)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{49,-388\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 49, -388\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 18 \\pmod{7}$\n$x \\equiv 15 \\pmod{11}$\n$x \\equiv 2 \\pmod{4}$\n$x \\equiv 20 \\pmod{9}$", + "Output Answer": [ + "$1082$" + ], + "Output Program": [ + "constraints = (18, 7), (15, 11), (2, 4), (20, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (18, 7), (15, 11), (2, 4), (20, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (18, 7), (15, 11), (2, 4), (20, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $671^m \\equiv 1 \\pmod{705}$.", + "Output Answer": [ + "$46$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(671, 705))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-405,796,243\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -405, 796, 243\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $811^m \\equiv 1 \\pmod{994}$.", + "Output Answer": [ + "$14$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(811, 994))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(35152)$.", + "Output Answer": [ + "$16224$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(35152))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-212,-482,217\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -212, -482, 217\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 1 \\pmod{2}$\n$x \\equiv 13 \\pmod{9}$\n$x \\equiv 15 \\pmod{19}$\n$x \\equiv 15 \\pmod{7}$", + "Output Answer": [ + "$1345$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (1, 2), (13, 9), (15, 19), (15, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (1, 2), (13, 9), (15, 19), (15, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (1, 2), (13, 9), (15, 19), (15, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(9146)$.", + "Output Answer": [ + "$4288$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(9146))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(37118)$.", + "Output Answer": [ + "$18216$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(37118))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1528$ is divisible by $45$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1528 % 45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19778)$.", + "Output Answer": [ + "$8400$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19778))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(11881)$.", + "Output Answer": [ + "$11772$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(11881))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $472^1565 \\pmod{1443}$.", + "Output Answer": [ + "$1336$" + ], + "Output Program": [ + "print(pow(472, 1565, 1443))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56376 \\pmod{54}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(56376 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 20 \\pmod{15}$\n$x \\equiv 18 \\pmod{11}$", + "Output Answer": [ + "$95$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (20, 15), (18, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (20, 15), (18, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "import math\n\nconstraints = (20, 15), (18, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $43^m \\equiv 1 \\pmod{140}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(43, 140))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1535^1412 \\pmod{2699}$.", + "Output Answer": [ + "$51$" + ], + "Output Program": [ + "print(pow(1535, 1412, 2699))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2055^1122 \\pmod{2864}$.", + "Output Answer": [ + "$2369$" + ], + "Output Program": [ + "print(pow(2055, 1122, 2864))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 7072 \\pmod{14}$.", + "Output Answer": [ + "$2$" + ], + "Output Program": [ + "print(7072 % 14)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2176^1448 \\pmod{2744}$.", + "Output Answer": [ + "$1688$" + ], + "Output Program": [ + "print(pow(2176, 1448, 2744))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-702,-37\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -702, -37\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{13}$\n$x \\equiv 8 \\pmod{5}$\n$x \\equiv 10 \\pmod{3}$", + "Output Answer": [ + "$73$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 13), (8, 5), (10, 3)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 13), (8, 5), (10, 3)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 13), (8, 5), (10, 3)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n76131", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(76131))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $264^m \\equiv 1 \\pmod{287}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(264, 287))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 4794 \\pmod{94}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(4794 % 94)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 53181 \\pmod{56}$.", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "print(53181 % 56)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1392^1111 \\pmod{2464}$.", + "Output Answer": [ + "$160$" + ], + "Output Program": [ + "print(pow(1392, 1111, 2464))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(10347)$.", + "Output Answer": [ + "$6896$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(10347))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{99}{1064}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{4538185}-99}{2128}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(99/1064)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12653)$.", + "Output Answer": [ + "$12652$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12653))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 69755 \\pmod{71}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "print(69755 % 71)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $127x \\equiv 1 \\pmod{460}$.", + "Output Answer": [ + "$163$" + ], + "Output Program": [ + "print(pow(127, -1, 460))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1014^1512 \\pmod{1675}$.", + "Output Answer": [ + "$1496$" + ], + "Output Program": [ + "print(pow(1014, 1512, 1675))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{3469}{4322}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{86752697}-3469}{8644}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(3469/4322)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n15443", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(15443))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $479^m \\equiv 1 \\pmod{933}$.", + "Output Answer": [ + "$62$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(479, 933))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{30906}{2111}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{243251530}-15453}{2111}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(30906/2111)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $38042$ is divisible by $-46$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(38042 % -46 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-381,873\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -381, 873\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $117x \\equiv 1 \\pmod{368}$.", + "Output Answer": [ + "$173$" + ], + "Output Program": [ + "print(pow(117, -1, 368))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 44156 \\pmod{88}$.", + "Output Answer": [ + "$68$" + ], + "Output Program": [ + "print(44156 % 88)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $769x \\equiv 1 \\pmod{2358}$.", + "Output Answer": [ + "$601$" + ], + "Output Program": [ + "print(pow(769, -1, 2358))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $39406$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(39406 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $185^988 \\pmod{497}$.", + "Output Answer": [ + "$81$" + ], + "Output Program": [ + "print(pow(185, 988, 497))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $30400$ is divisible by $25$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(30400 % 25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2239$ to base $28$.", + "Output Answer": [ + "$\\text{2nr}_{28}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 28\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2239\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n13231", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(13231))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $17280$ is divisible by $45$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(17280 % 45 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2797}{44396}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{7891842473}-2797}{88792}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2797/44396)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $237x \\equiv 1 \\pmod{2237}$.", + "Output Answer": [ + "$1312$" + ], + "Output Program": [ + "print(pow(237, -1, 2237))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $516^2172 \\pmod{1174}$.", + "Output Answer": [ + "$642$" + ], + "Output Program": [ + "print(pow(516, 2172, 1174))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{8}$\n$x \\equiv 18 \\pmod{10}$\n$x \\equiv 17 \\pmod{19}$\n$x \\equiv 20 \\pmod{18}$", + "Output Answer": [ + "$5888$" + ], + "Output Program": [ + "constraints = (16, 8), (18, 10), (17, 19), (20, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 8), (18, 10), (17, 19), (20, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1731x \\equiv 1 \\pmod{2096}$.", + "Output Answer": [ + "$379$" + ], + "Output Program": [ + "print(pow(1731, -1, 2096))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $1616$ is divisible by $-38$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(1616 % -38 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19979)$.", + "Output Answer": [ + "$19978$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19979))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 59855 \\pmod{28}$.", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "print(59855 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 58945 \\pmod{28}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "print(58945 % 28)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n18223", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(18223))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $523x \\equiv 1 \\pmod{1000}$.", + "Output Answer": [ + "$587$" + ], + "Output Program": [ + "print(pow(523, -1, 1000))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 1905 \\pmod{7}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "print(1905 % 7)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{367}{567}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{1420645}-367}{1134}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(367/567)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 14802 \\pmod{75}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(14802 % 75)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-12551$ is divisible by $49$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-12551 % 49 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $721^m \\equiv 1 \\pmod{900}$.", + "Output Answer": [ + "$5$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(721, 900))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 50231 \\pmod{94}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(50231 % 94)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\n\nDetermine the $n=12$ $43$-gonal number.\n", + "Output Answer": [ + "$9073$" + ], + "Output Program": [ + "n = 12\nk = 43\nprint(1 + (n - 1) * (k - 1) + ((k - 2) * (k - 1) * (n - 2)) // 2)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{565,-927\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 565, -927\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 5 \\pmod{8}$\n$x \\equiv 8 \\pmod{5}$\n$x \\equiv 15 \\pmod{9}$", + "Output Answer": [ + "$213$" + ], + "Output Program": [ + "import math\n\nconstraints = (5, 8), (8, 5), (15, 9)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (5, 8), (8, 5), (15, 9)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (5, 8), (8, 5), (15, 9)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(20096)$.", + "Output Answer": [ + "$9984$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(20096))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 15 \\pmod{3}$\n$x \\equiv 3 \\pmod{4}$\n$x \\equiv 15 \\pmod{13}$\n$x \\equiv 8 \\pmod{5}$", + "Output Answer": [ + "$483$" + ], + "Output Program": [ + "constraints = (15, 3), (3, 4), (15, 13), (8, 5)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (15, 3), (3, 4), (15, 13), (8, 5)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (15, 3), (3, 4), (15, 13), (8, 5)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 36400 \\pmod{58}$.", + "Output Answer": [ + "$34$" + ], + "Output Program": [ + "print(36400 % 58)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(22976)$.", + "Output Answer": [ + "$11456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(22976))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $509x \\equiv 1 \\pmod{1810}$.", + "Output Answer": [ + "$889$" + ], + "Output Program": [ + "print(pow(509, -1, 1810))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{3}$\n$x \\equiv 8 \\pmod{11}$", + "Output Answer": [ + "$19$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (7, 3), (8, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (7, 3), (8, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (7, 3), (8, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-248,-137\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -248, -137\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{5}$\n$x \\equiv 4 \\pmod{3}$\n$x \\equiv 15 \\pmod{7}$", + "Output Answer": [ + "$22$" + ], + "Output Program": [ + "import math\n\nconstraints = (17, 5), (4, 3), (15, 7)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (17, 5), (4, 3), (15, 7)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (17, 5), (4, 3), (15, 7)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-631,-25\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -631, -25\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $0.635$ to base $2$.", + "Output Answer": [ + "$0.1010001010001111011_2$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 2\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 0.635\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-144,222\\}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "import math\n\nvalues = -144, 222\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1455^841 \\pmod{1971}$.", + "Output Answer": [ + "$702$" + ], + "Output Program": [ + "print(pow(1455, 841, 1971))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(768)$.", + "Output Answer": [ + "$256$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(768))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-815,92\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -815, 92\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $474^m \\equiv 1 \\pmod{499}$.", + "Output Answer": [ + "$498$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(474, 499))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1355^1262 \\pmod{2176}$.", + "Output Answer": [ + "$1545$" + ], + "Output Program": [ + "print(pow(1355, 1262, 2176))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n91083", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(91083))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 87218 \\pmod{54}$.", + "Output Answer": [ + "$8$" + ], + "Output Program": [ + "print(87218 % 54)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-3354$ is divisible by $12$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-3354 % 12 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $193^m \\equiv 1 \\pmod{207}$.", + "Output Answer": [ + "$33$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(193, 207))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-62197$ is divisible by $37$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-62197 % 37 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 17 \\pmod{13}$\n$x \\equiv 0 \\pmod{2}$\n$x \\equiv 0 \\pmod{11}$", + "Output Answer": [ + "$264$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (17, 13), (0, 2), (0, 11)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "import math\n\nconstraints = (17, 13), (0, 2), (0, 11)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "constraints = (17, 13), (0, 2), (0, 11)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 55738 \\pmod{69}$.", + "Output Answer": [ + "$55$" + ], + "Output Program": [ + "print(55738 % 69)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $812^1825 \\pmod{2636}$.", + "Output Answer": [ + "$1884$" + ], + "Output Program": [ + "print(pow(812, 1825, 2636))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $662^305 \\pmod{1986}$.", + "Output Answer": [ + "$662$" + ], + "Output Program": [ + "print(pow(662, 305, 1986))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-22,313,422\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -22, 313, 422\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{166,546,81\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 166, 546, 81\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $735^2244 \\pmod{1959}$.", + "Output Answer": [ + "$492$" + ], + "Output Program": [ + "print(pow(735, 2244, 1959))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-17934$ is divisible by $21$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-17934 % 21 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 3138 \\pmod{84}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "print(3138 % 84)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $140^m \\equiv 1 \\pmod{197}$.", + "Output Answer": [ + "$196$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(140, 197))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{82,-393,-801\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 82, -393, -801\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $269^2101 \\pmod{1985}$.", + "Output Answer": [ + "$334$" + ], + "Output Program": [ + "print(pow(269, 2101, 1985))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 54969 \\pmod{90}$.", + "Output Answer": [ + "$69$" + ], + "Output Program": [ + "print(54969 % 90)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $217^m \\equiv 1 \\pmod{783}$.", + "Output Answer": [ + "$28$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(217, 783))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1532x \\equiv 1 \\pmod{2177}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(pow(1532, -1, 2177))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $1101x \\equiv 1 \\pmod{1832}$.", + "Output Answer": [ + "$1629$" + ], + "Output Program": [ + "print(pow(1101, -1, 1832))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-199$ is divisible by $28$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(-199 % 28 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n1087", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1087))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-372,675,97\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = -372, 675, 97\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 85397 \\pmod{95}$.", + "Output Answer": [ + "$87$" + ], + "Output Program": [ + "print(85397 % 95)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{277,-856,787\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 277, -856, 787\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n97771", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(97771))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n1579", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(1579))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2011_4$ to base 10.", + "Output Answer": [ + "$133$" + ], + "Output Program": [ + "n = '2011'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-567,880\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -567, 880\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1499^942 \\pmod{2888}$.", + "Output Answer": [ + "$2553$" + ], + "Output Program": [ + "print(pow(1499, 942, 2888))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $120^m \\equiv 1 \\pmod{709}$.", + "Output Answer": [ + "$708$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(120, 709))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18960)$.", + "Output Answer": [ + "$4992$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18960))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $113^m \\equiv 1 \\pmod{533}$.", + "Output Answer": [ + "$30$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(113, 533))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 16 \\pmod{5}$\n$x \\equiv 15 \\pmod{2}$\n$x \\equiv 6 \\pmod{15}$", + "Output Answer": [ + "$21$" + ], + "Output Program": [ + "constraints = (16, 5), (15, 2), (6, 15)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (16, 5), (15, 2), (6, 15)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{83,-902,-945\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 83, -902, -945\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{978,772\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 978, 772\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 2 \\pmod{5}$\n$x \\equiv 11 \\pmod{2}$\n$x \\equiv 9 \\pmod{14}$", + "Output Answer": [ + "$37$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (2, 5), (11, 2), (9, 14)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (2, 5), (11, 2), (9, 14)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(12598)$.", + "Output Answer": [ + "$6298$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(12598))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-254,-751\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -254, -751\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $35_{11}$ to base 10.", + "Output Answer": [ + "$38$" + ], + "Output Program": [ + "n = '35'.strip('.')\nbase = 11\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 48301 \\pmod{59}$.", + "Output Answer": [ + "$39$" + ], + "Output Program": [ + "print(48301 % 59)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{17333}{8511}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{590181373}-17333}{17022}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(17333/8511)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 49643 \\pmod{85}$.", + "Output Answer": [ + "$3$" + ], + "Output Program": [ + "print(49643 % 85)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $317^m \\equiv 1 \\pmod{875}$.", + "Output Answer": [ + "$300$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(317, 875))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(36240)$.", + "Output Answer": [ + "$9600$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(36240))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $205x \\equiv 1 \\pmod{2367}$.", + "Output Answer": [ + "$1120$" + ], + "Output Program": [ + "print(pow(205, -1, 2367))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 3 \\pmod{19}$\n$x \\equiv 6 \\pmod{14}$\n$x \\equiv 6 \\pmod{18}$", + "Output Answer": [ + "$1770$" + ], + "Output Program": [ + "from sympy.ntheory.modular import *\n\nconstraints = (3, 19), (6, 14), (6, 18)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (3, 19), (6, 14), (6, 18)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $1^m \\equiv 1 \\pmod{453}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(1, 453))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $21^1981 \\pmod{2653}$.", + "Output Answer": [ + "$2513$" + ], + "Output Program": [ + "print(pow(21, 1981, 2653))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $1222212_3$ to base 10.", + "Output Answer": [ + "$1454$" + ], + "Output Program": [ + "n = '1222212'.strip('.')\nbase = 3\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(29913)$.", + "Output Answer": [ + "$18096$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(29913))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $389x \\equiv 1 \\pmod{546}$.", + "Output Answer": [ + "$233$" + ], + "Output Program": [ + "print(pow(389, -1, 546))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $271^m \\equiv 1 \\pmod{378}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(271, 378))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $2227^2496 \\pmod{2322}$.", + "Output Answer": [ + "$1225$" + ], + "Output Program": [ + "print(pow(2227, 2496, 2322))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 80167 \\pmod{52}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(80167 % 52)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $5066$ is divisible by $34$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(5066 % 34 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 61101 \\pmod{67}$.", + "Output Answer": [ + "$64$" + ], + "Output Program": [ + "print(61101 % 67)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n45521", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(45521))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $686^67 \\pmod{1819}$.", + "Output Answer": [ + "$743$" + ], + "Output Program": [ + "print(pow(686, 67, 1819))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(13680)$.", + "Output Answer": [ + "$3456$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(13680))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n5145", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(5145))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{887,-28,-182\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = 887, -28, -182\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{427,907,-460\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = 427, 907, -460\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $11422$.", + "Output Answer": [ + "$\\{19,29,31,43,57,67,73,79,87,89\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(11422):\n if len(roots) == 10: break\n if gcd(a, 11422) == 1 and is_primitive_root(a, 11422):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $249^m \\equiv 1 \\pmod{578}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(249, 578))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $23297$.", + "Output Answer": [ + "$\\{3,5,10,11,17,19,20,21,23,24\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(23297):\n if len(roots) == 10: break\n if gcd(a, 23297) == 1 and is_primitive_root(a, 23297):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{36114}{5113}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{352198018}-18057}{5113}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(36114/5113)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $244^m \\equiv 1 \\pmod{817}$.", + "Output Answer": [ + "$126$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(244, 817))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $530^m \\equiv 1 \\pmod{759}$.", + "Output Answer": [ + "$10$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(530, 759))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $24x \\equiv 1 \\pmod{829}$.", + "Output Answer": [ + "$380$" + ], + "Output Program": [ + "print(pow(24, -1, 829))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $233x \\equiv 1 \\pmod{1443}$.", + "Output Answer": [ + "$545$" + ], + "Output Program": [ + "print(pow(233, -1, 1443))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 70386 \\pmod{31}$.", + "Output Answer": [ + "$16$" + ], + "Output Program": [ + "print(70386 % 31)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $463^m \\equiv 1 \\pmod{921}$.", + "Output Answer": [ + "$153$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(463, 921))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $79937$ is divisible by $43$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(79937 % 43 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $73749$ is divisible by $39$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(73749 % 39 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $296^m \\equiv 1 \\pmod{659}$.", + "Output Answer": [ + "$94$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(296, 659))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $649^m \\equiv 1 \\pmod{670}$.", + "Output Answer": [ + "$66$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(649, 670))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5607}{7874}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{279437953}-5607}{15748}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5607/7874)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $-24057$ is divisible by $33$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "print(-24057 % 33 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{828,-400\\}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "import math\n\nvalues = 828, -400\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $90^1250 \\pmod{1569}$.", + "Output Answer": [ + "$144$" + ], + "Output Program": [ + "print(pow(90, 1250, 1569))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n7523", + "Output Answer": [ + "\\text{True}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(7523))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1759^254 \\pmod{2388}$.", + "Output Answer": [ + "$721$" + ], + "Output Program": [ + "print(pow(1759, 254, 2388))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1764}{1649}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{139885}-882}{1649}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1764/1649)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $299$ is divisible by $-18$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(299 % -18 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 56657 \\pmod{64}$.", + "Output Answer": [ + "$17$" + ], + "Output Program": [ + "print(56657 % 64)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $198^m \\equiv 1 \\pmod{787}$.", + "Output Answer": [ + "$786$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(198, 787))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $193^m \\equiv 1 \\pmod{298}$.", + "Output Answer": [ + "$4$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(193, 298))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(31631)$.", + "Output Answer": [ + "$30912$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(31631))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $798x \\equiv 1 \\pmod{1019}$.", + "Output Answer": [ + "$936$" + ], + "Output Program": [ + "print(pow(798, -1, 1019))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 47555 \\pmod{48}$.", + "Output Answer": [ + "$35$" + ], + "Output Program": [ + "print(47555 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 8 \\pmod{11}$\n$x \\equiv 20 \\pmod{17}$\n$x \\equiv 12 \\pmod{6}$", + "Output Answer": [ + "$360$" + ], + "Output Program": [ + "import math\n\nconstraints = (8, 11), (20, 17), (12, 6)\na_lst, m_lst = zip(*constraints)\nM = math.prod(m_lst)\nb_lst = [M // m for m in m_lst]\nb_prime_lst = [pow(b, -1, m) for b, m in zip(b_lst, m_lst)]\nx = sum(a * b * b_prime for a, b, b_prime in zip(a_lst, b_lst, b_prime_lst)) % M\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (8, 11), (20, 17), (12, 6)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n", + "constraints = (8, 11), (20, 17), (12, 6)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFactor $9078$.", + "Output Answer": [ + "$2^1\\cdot 3^1\\cdot 17^1\\cdot 89^1$" + ], + "Output Program": [ + "from sympy import *\n\nprint(factorint(9078))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $7^m \\equiv 1 \\pmod{592}$.", + "Output Answer": [ + "$18$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(7, 592))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIs the following number prime?\n27009", + "Output Answer": [ + "\\text{False}" + ], + "Output Program": [ + "from sympy.ntheory import * \n\nprint(isprime(27009))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 76539 \\pmod{48}$.", + "Output Answer": [ + "$27$" + ], + "Output Program": [ + "print(76539 % 48)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{23125}{19984}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{2132206649}-23125}{39968}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(23125/19984)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $73x \\equiv 1 \\pmod{579}$.", + "Output Answer": [ + "$349$" + ], + "Output Program": [ + "print(pow(73, -1, 579))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(19488)$.", + "Output Answer": [ + "$5376$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(19488))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $13120_4$ to base 10.", + "Output Answer": [ + "$472$" + ], + "Output Program": [ + "n = '13120'.strip('.')\nbase = 4\nif '.' in n:\n num, frac = n.split('.')\n magnitude = len(frac)\n dec = int(num, base) + int(frac, base) / pow(base, magnitude)\n print(dec)\nelse: print(int(n, base))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $461x \\equiv 1 \\pmod{1272}$.", + "Output Answer": [ + "$149$" + ], + "Output Program": [ + "print(pow(461, -1, 1272))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that\n$x \\equiv 7 \\pmod{8}$\n$x \\equiv 3 \\pmod{4}$", + "Output Answer": [ + "$7$" + ], + "Output Program": [ + "constraints = (7, 8), (3, 4)\nx = 0\nwhile not all(a % m == x % m for a, m in constraints):\n x += 1\nprint(x)\n\n", + "from sympy.ntheory.modular import *\n\nconstraints = (7, 8), (3, 4)\na_lst, m_lst = zip(*constraints)\nprint(min(crt(m_lst, a_lst)))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-527,-458\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -527, -458\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $16650$ is divisible by $-40$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(16650 % -40 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $451x \\equiv 1 \\pmod{854}$.", + "Output Answer": [ + "$89$" + ], + "Output Program": [ + "print(pow(451, -1, 854))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1467^1058 \\pmod{2265}$.", + "Output Answer": [ + "$2214$" + ], + "Output Program": [ + "print(pow(1467, 1058, 2265))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $457x \\equiv 1 \\pmod{2160}$.", + "Output Answer": [ + "$553$" + ], + "Output Program": [ + "print(pow(457, -1, 2160))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nCompute the Euler totient function $\\phi(18943)$.", + "Output Answer": [ + "$17928$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(totient(18943))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nDetermine whether $4165$ is divisible by $25$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "print(4165 % 25 == 0)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{88,764,179\\}$.", + "Output Answer": [ + "$\\text{False}$" + ], + "Output Program": [ + "import math\n\nvalues = 88, 764, 179\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nSimplify $1270^1217 \\pmod{2359}$.", + "Output Answer": [ + "$145$" + ], + "Output Program": [ + "print(pow(1270, 1217, 2359))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2763}{13657}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{753688765}-2763}{27314}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2763/13657)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $98^m \\equiv 1 \\pmod{837}$.", + "Output Answer": [ + "$6$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(98, 837))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{2241}{1165}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{10450981}-2241}{2330}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(2241/1165)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nAre the following numbers relatively prime (coprime)? $\\{-885,-427,247\\}$.", + "Output Answer": [ + "$\\text{True}$" + ], + "Output Program": [ + "import math\n\nvalues = -885, -427, 247\nprint(all(math.gcd(i, j) == 1 for i in values for j in values if i != j))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nReturn up to the first 10 primitive roots of $5197$.", + "Output Answer": [ + "$\\{7,19,21,22,23,28,37,43,53,55\\}$." + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nroots = list()\nfor a in range(5197):\n if len(roots) == 10: break\n if gcd(a, 5197) == 1 and is_primitive_root(a, 5197):\n roots.append(a)\nprint(roots)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{5311}{407}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{814} \\left(\\sqrt{28869317}-5311\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(5311/407)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nConvert $2453$ to base $22$.", + "Output Answer": [ + "$\\text{51b}_{22}$" + ], + "Output Program": [ + "import math\n\ndigits = '0123456789abcdefghijklmnopqrstuvwxyz'\nbase = 22\n\ndef decimal_to_base(dec, place):\n if math.isclose(dec, 0) or place < -4:\n return ''\n else:\n point = '.' if not place else ''\n d, m = divmod(dec, pow(base, place))\n digit = digits[int(d)]\n others = decimal_to_base(m, place - 1)\n return digit + point + others\n\ndecimal = 2453\nplace = 0 if not decimal else int(math.log(decimal, base))\nprint(decimal_to_base(decimal, place).strip('0') + f'_{base}')\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest $x$ such that $x \\equiv 22445 \\pmod{5}$.", + "Output Answer": [ + "$0$" + ], + "Output Program": [ + "print(22445 % 5)\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-526,237\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -526, 237\nprint(math.gcd(*values))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{1531}{8410}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{\\sqrt{285256361}-1531}{16820}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(1531/8410)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{4371}{182}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{1}{364} \\left(\\sqrt{19238137}-4371\\right)$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(4371/182)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nIf $x = \\frac{381}{2671}$, then find $\\frac{1}{x+\\frac{1}{x+\\frac{1}{x+\\ddots}}}$.", + "Output Answer": [ + "$\\frac{5 \\sqrt{1147285}-381}{5342}$" + ], + "Output Program": [ + "from sympy import *\nfrom sympy.ntheory import *\n\nprint(continued_fraction_reduce([[S('(381/2671)')]]))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the smallest integer $m$ such that $358^m \\equiv 1 \\pmod{877}$.", + "Output Answer": [ + "$876$" + ], + "Output Program": [ + "from sympy.ntheory import *\n\nprint(n_order(358, 877))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the modular multiplicative inverse $x$, or $x$ such that $115x \\equiv 1 \\pmod{136}$.", + "Output Answer": [ + "$123$" + ], + "Output Program": [ + "print(pow(115, -1, 136))\n" + ], + "split": "test" + }, + { + "Input": "Problem:\nFind the greatest common disvior of $\\{-739,-488\\}$.", + "Output Answer": [ + "$1$" + ], + "Output Program": [ + "import math\n\nvalues = -739, -488\nprint(math.gcd(*values))\n" + ], + "split": "test" + } + ] +} \ No newline at end of file