Questions tagged [number-theory]

Questions on the number-theoretic functionality of Mathematica.

Filter by
Sorted by
Tagged with
6 votes
4 answers
242 views

Generation of rational numbers under constraints

Working this question on Mathematics Stack Exchange, I have the following questions: how to generate a rational number $a$ such that $\sqrt{a^2-1}$ be also rational? This is the case of $a=\frac 54$. ...
7 votes
5 answers
351 views

Checking if a number is right sorted

I have a number $n$ such that the digits of $n$ are strictly increasing to the left except for the first digit. So for example when $n=51369$ fits the bill because: $$1<3<6<9\tag1$$ Is there ...
8 votes
6 answers
187 views

Counting zeros of list from twin primes calculation

...
1 vote
4 answers
220 views

Listing products of prime powers

Given a positive integer $n$, what is the code to list $2^{a_2}3^{a_3}\cdots p^{a_p}$, where $a_i\ge 0$ are integers, with respect to the lexicographic ordering on $(a_2,a_3,\ldots, a_p)$? The only ...
4 votes
5 answers
493 views

How to check if multiplication requires carries?

For some purposes I need to know if there are there any carries in the multiplication of two numbers, especially in base-2. How can we do this in Mathematica? Thanks to all, very interesting answers! ...
0 votes
1 answer
93 views

How to find value of variables so that my expression to be perfect squares?

Suppose I have the expression $$\sqrt{p(2-p)} \tag 1$$ and the expression $$ \sqrt{\frac{1}{4}\left( p-2 \right) ^2-\frac{4\left( p-1 \right) ^4}{\left( p-2 \right) ^2}}. \tag 2 $$ The Mathematica ...
3 votes
0 answers
71 views

PrimeZetaP evaluation in different versions of Mathematica

PrimeZetaP was introduced in version 7.0. I suspect there were made some changes in the definition of this function in subsequent versions. Is there any user that ...
0 votes
1 answer
151 views

PartitionsP for non-integer arguments [closed]

Is there a reason why the function PartitionsP[] does not return anything for non-integer arguments, although there is a way to calculate using Rademacher’s ‘exact’ ...
1 vote
0 answers
117 views

Does a(a+1)(a+2)-1=b²+2=10c+3 have solutions over natural numbers? If yes, how many?

It is a question from the math olympiad I was participating in that happened like a month ago. The provided solution turned out to be wrong. It isn't the question itself, but the solution basically ...
9 votes
5 answers
3k views

Digits of Pi in colored spiral

In How to make the digits of π go around in a spiral like this? it is described how to plot pi in a spiralform (in my case as binary number): ...
3 votes
2 answers
176 views

Select a subset in the bit-strings with even 1s overlapped - thank you

Model 1 Consider the permutation list of 4-bit-strings: list = Permutations[{0, 0, 1, 1}, {4}] which outputs: {{0, 0, 1, 1}, {0, 1, 0, 1}, {0, 1, 1, 0}, {1, 0, 0, ...
11 votes
8 answers
1k views

Transform a number to a factorial

I came across the need to transform a number into a factorial n, with positive integer n. I have searched in the MMA information but I can't find anything like that. I imagine an input, which verifies ...
8 votes
2 answers
634 views

Better code for Ramsey partitions

Ramsey partitions for parameters $a$ and $b$ are certain integer partition of $a+b$ developed by McAvaney, Robertson, and Webb (Combinatorica 1992) for applications in fair division problems where two ...
2 votes
6 answers
477 views

All solutions that satisfy $ x_{1}^{5}+x_{2}^{5}+x_{3}^{5}+x_{4}^{5}-x_{5}^{5}=0 $

I want to find a combination that satisfies all the solutions of the following formula. $$ x_{1}^{5}+x_{2}^{5}+x_{3}^{5}+x_{4}^{5}-x_{5}^{5}=0 $$ $x_{1}$, $x_{2}$, $x_{3}$, $x_{4}$, and $x_{5}$ are ...
3 votes
1 answer
152 views

How to make a function that returns all super distinct partitions?

I am working on distinct partitions. I recently created a function StrictIntegerPartitions. This is from the book Integer Partitions by George E. Andrews at Pennsylvania State University and Kimmo ...
5 votes
2 answers
203 views

How to make FactorInteger iterative?

I want to factorize big numbers like 10^100. FactorInteger with no Automatic option can take a lot of time and as I know there ...
0 votes
0 answers
48 views

Manipulating Dirichlet characters and L functions

I read some basic knowledge about characters and L functions, and would like to play around with them in MMA. I tried to do the following things, but ending in minor success. (MMA notation used) ...
3 votes
1 answer
155 views

Mathematica code for q-Stirling numbers

In the paper [A new $q$-Analog of Stirling Numbers],(https://hal.archives-ouvertes.fr/hal-01372920/document)[PDF] J. Cigler defined $q$-Stirling numbers of the second kind as the following: He ...
8 votes
4 answers
727 views

Design a function that gives all strict partitions of an integer

A strict partition of an integer has all distinct parts. There are no duplicates like 1 in {5,3,1,1} for 10. All the parts are unique. Sylvester created a bijection between the partitions of an ...
3 votes
1 answer
152 views

Faster PowersRepresentation using IntegerPartitions

Earlier I posted a question about taking fast integer square roots of known integer perfect squares. The reason this came up is I was trying to find a faster way of mimicking the PowersRepresentations[...
0 votes
1 answer
60 views

Does applying Reduce result in an equivalence or a oneway implication or both? [closed]

If I type something like this into Mathematica: ...
7 votes
5 answers
2k views

Perfect numbers

The question given to me: a. Find the perfect numbers between $1$ and $10^6$ b: Find the abundant numbers between $1$ and $1000$ For a, I wrote ...
3 votes
4 answers
1k views

Solve Olympiad Problem with Mma

Find all integers $k\le100$, so that there exists an integer $n$, satisfying \[k\mid3n^6+26n^4+33n^2+1.\] By number theory knowledge it suffices to check $n\in[1,k]$, but we'll do $[1,100]$ for ...
9 votes
2 answers
2k views

Elliptic curve cryptography in Mathematica

I can find no resources for doing elliptic curve cryptography. I have used the finite field package, but I find it cumbersome and it does not seem to have any builtin methods for ECC. How can I get ...
3 votes
2 answers
821 views

Some information about PrimeQ function

In Mathematica there is a built-in function called PrimeQ which tests given input as True or ...
3 votes
2 answers
105 views

Check certain expression using a while loop to run through all posibilities in a range

Well, I have written the following code (using the fast square root test found in this answer): ...
1 vote
1 answer
118 views

Trouble implementing a simple algorithm for solving the DLP

I have some trouble implementing a simple algorithm for solving the DLP in F_p^* using Mathematica. The algoritm should look as follow: ...
2 votes
0 answers
44 views

Using "ToNumberField" as opposed to equations over the integers

Let D>1 be a square-free rational integer, and write \Q for the rationals. I am trying to determine the (non-)membership of ...
1 vote
1 answer
96 views

Why do some functions, or at least, PowersRepresentations, run far faster on subsequent calls? What determines this behaviour?

Say I run the following: PowersRepresentations[4782969,4,2] and it takes about 2 minutes. If I call it again it takes only about 0.0005 seconds. What determines ...
3 votes
0 answers
142 views

DirichletTransform gives incorrect result

Bug introduced in 13.0 or earlier and persisting through 13.2.0 or later. Input 1: ...
1 vote
1 answer
84 views

Select primes from their Zeckendorf representation

I'm working with the Zeckendorf representation of prime numbers. I'm using ResourceFunction["ZeckendorfRepresentation"][Prime[n]] and I would like to select from all the results, the ones ...
1 vote
1 answer
65 views

Representing a number in r0 + r1 E + r2 E^2 form

Let E be the base of natural logarithm 2.71... A Sequence S[n] is believed to converge to a ...
2 votes
3 answers
321 views

How to determine the unique combination of digits satisfying a given relation?

Is there a method to determine the unique combination of numbers a, b, c and d which satisfy the relation below, and which yields the output with the numbers in the given order. Example for 2023 is ...
9 votes
5 answers
2k views

Implementing the Farey sequence efficiently

There is of course the silly implementation: FareySequence[n_] := Union[Flatten[Table[j/i, {i, 1, n}, {j, 0, i}]]] However, there are numerous properties and ...
5 votes
2 answers
637 views

Can I use NextPrime[n] up to n=10^14?

I would like to perform computations with primes up to $n=10^{14}$. To do so, I would like to go through all primes, from $2$ to $10^{14}$ and perform some calculation on each prime. I saw that one ...
3 votes
6 answers
640 views

How to ask Mathematica to compute the given sum of the differences of the numbers of the given two sets?

I have two sets of real numbers, say, set1= {b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11} ...
1 vote
1 answer
143 views

A square board of size n*n [closed]

I would like to Randomly generate n^2 natural numbers in an interval from 1 to n. Then consider placing each number on the cell with the same number (you can imagine the board numbered naturally, row ...
2 votes
2 answers
186 views

Writing the number '80668227' as a sums of 4 & 5 cubes

I need to write the number '80668227' as a sum of 4 & 5 cubes. I tried this code PowersRepresentations[80668227, 4, 3] in Mathematica but the above code is ...
6 votes
0 answers
74 views

Dedekind Zeta Function in Mathematica (at least for quadratic number field)

Does there exist some way to use Mathematica to compute the Dedekind Zeta function for an arbitrary algebraic number field? Or does there exist some package to do this? I am actually only interested ...
8 votes
3 answers
1k views

On a strange pattern of triangular numbers in Ulam's spiral

In this MSE post, user GeMir noticed that, (source: mathforum.org) where the green dots are the triangular numbers, $$T_n = \frac{n(n+1)}{2} = 1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,\dots$$ ...
4 votes
3 answers
336 views

Find all sets whose index is divisible by the elements

Suppose I have such a set $S=\{3,4,5,...n+2\}, n\in \mathbb{Z}_{>\, 0} $, $a_n$ is any permutation of $S$ such that $n|a_n$, I want to know how many such $a_n$. The easy but inefficient way to do ...
58 votes
3 answers
6k views

What is so special about Prime?

When we try to evaluate Prime on big numbers (e.g. 10^13) we encounter the following issue: ...
5 votes
4 answers
1k views

Finding least n such that n^2 + 23 is divisible by large powers of 2

Lets say that we want to find the least n such that n^2+23 is divisible by 2^100. We can compute this in one line using the Pari/GP language: ...
3 votes
4 answers
101 views

How to Make a list or table containing the product of every three digit integer in mathematica

I am trying to learn the mathematica language. And it was suggested to me to start by doing the Project Euler problems. I am currently working on Problem # 4: A palindromic number reads the same both ...
3 votes
3 answers
380 views

Selecting two numbers to make an integer value

Suppose that the general equation $f(x,y) = x + y + Sqrt[x*y]$ is to be used to find the values of $x$ and $y$ such that $f(x,y)$ is an integer, ideally using ...
4 votes
2 answers
97 views

Test if the decimal digits of $n$ appear $n$ times in the decimal representation of $n!$

I want to find numbers $n$ for which the decimal digits of $n$ appear $n$ times in the decimal representation of $n!$. For instance, $n\in\left\{0, 1, 1170, 1528, 9877, 9886, 9897, 11535\right\}$ are ...
4 votes
3 answers
745 views

Solving a system of diophantine equations from a mathematical competition

There is a problem from the $66th$ Putnam Mathematical Competition, $B2$ Find all positive integers $n,k_1,k_2,...,k_n$ such that $$k_1+\cdots+k_n=5n-4$$ and $$\frac{1}{k_1}+\cdots+\frac{1}{...
3 votes
2 answers
175 views

System of equations

I am trying to find ALL or a list of possible values for x satisfying: x MOD 9 ==2 AND (x+631) MOD 9 = 3 Using Mathematica. can anyone help? 2 is not the only answer 497 is another one since 497 mod ...
1 vote
2 answers
470 views

How to solve equations in Gaussian integers modulo p

How to solve a complex equation of the form: $$z^n \equiv i \pmod p$$ where $z$ is a Gaussian integer, $i$ is the imaginary number, $n, p \in \mathbb{Z}^+$ and $p$ is prime. I am dealing with quite ...
6 votes
2 answers
113 views

Reduce an expression where the variables can assume only $\pm 1$

I would like to solve this equation: x1y1 + x2y2 + x3y3 + x4y4 = 0 and I would like to count the number of distict solutions. Here $x_1,\dots,x_4$ and $y_1,\dots,...

1
2 3 4 5
9