Questions tagged [number-theory]

Questions on the number-theoretic functionality of Mathematica.

Filter by
Sorted by
Tagged with
1
vote
1answer
67 views

Converting sequece of code into a function [closed]

I constructed a pretty basic sieve of Eratosthenes and would like to use it as a function rather than copy pasting output, how do I achieve ...
1
vote
1answer
55 views

Code needed to determine the smallest k that the equation will fail by brute force [closed]

I find one of the suggested solution to this problem a little bit questionable: “If N is divisible by 1, 2, 3,. . . M, then N must also be divisible by M + 1, M + 2, M + 3, . . . M + k for k is a ...
-3
votes
2answers
346 views

Solving a diophantine equation with three variables

Solve this equation using Mathematica: $2^x + 113^y = z^2$, $\operatorname{gcd}(x, y) = 1$.
0
votes
1answer
69 views

Having a Problem with Manipulate

I'm trying to work out a new way of visualizing the Collatz conjecture (or 3n+1 problem) using the Manipulate feature of Mathematica to show paths that numbers take in the 3n+1 problem in the form of ...
3
votes
1answer
105 views

Having problems with Manipulate

I'm trying to create a diagram that could be used to visualize the Collatz Conjecture in a new way, but I can't get Manipulate to work in the way I want it to. The goal of the program is to have m ...
3
votes
1answer
124 views

Where is the Chebyshev function of the second kind in Mathematica/Alpha?

I need to perform some computations involving the Chebyshev function of the second kind (sometimes also called the summatory Von Mangoldt function) $\psi(x)$, defined as $$\psi(x) = \sum_{n\le x} \...
-1
votes
1answer
109 views

Plotting Poset Relations in Mathematica [closed]

Let $n$ be a positive integer and let $p$ denote the largest prime $\le n$. Let $i=2^{a_2}3^{a_3}5^{a_5}\cdots p^{a_p}$, $a_l\ge 0$. For nonprimes $s,t\le n$, we say $s\le t$ (poset relation) if, for ...
1
vote
1answer
157 views

Summing over Prime Factors (without repetition)

Wolfram Mathworld (http://mathworld.wolfram.com/SumofPrimeFactors.html) describes a function sopfr(n), the sum of prime factors, which I currently need. This code doesn't work when I insert it in ...
0
votes
1answer
107 views

Hecke Operator- sum over divisors of a number

I am trying to write out the Hecke Operator; however, I don't know how to sum over all divisors of an integer. Could someone please give me some advice how to do that. Below is the Hecke Operator ...
4
votes
2answers
174 views

Sum indexed by Primes [duplicate]

How can I express a sum indexed by primes in Mathematica? Two examples that I am interested in are (1) where the primes go from $p=2$ to, say, $p=17$. (2) It would also be useful to have the sum ...
5
votes
1answer
475 views

Solving a Diophantine equation with a large solution

I am trying to solve the following Diophantine equation with Mathematica: $\frac{x}{y+z}+\frac{z}{x+y}+\frac{y}{x+z}=4$ It is known that there are three positive numbers that satisfy the equation ...
-5
votes
3answers
126 views

Finding all the perfect integers below 10000 [closed]

I have a homework problem about perfect numbers. I simply did it, but I need to use Divisors, Most, ...
6
votes
2answers
880 views

How can I solve a certain congruence equation?

I want to solve the congruence $3x^2 + 6x + 1 \equiv 0 \pmod {19}$. I know that one way to solve this is to first solve the congruence: $t^2 \equiv 5 \pmod {19}$, because $b^2 - 4ac \equiv 24 \equiv ...
1
vote
1answer
91 views

Decoding Message-Signature Pairs

I've been given a set of message-signature pairs to decrypt using a public RSA key I set up. I need to sort through the decoded messages, and find which of those have a valid signature. My public key ...
1
vote
0answers
145 views

What is the shortest way to calculate Euler's Phi function ( excluding EulerPhi )?

With the risk of closure by the duplicate zombies ( this one might do: How can I write the natural numbers less than $n$ that are coprime to $n$? ) I dare to ask the following question. My hobby ...
0
votes
1answer
73 views

Find a number's digits in an arbitrary base [closed]

I want to write a program in Mathematica which for an input $n$ gives me a representation in a number system of base 26. For example, $$1419=2\cdot 26^2+2\cdot 26+15.$$ The output I am looking for is ...
2
votes
0answers
65 views

Introducing constraints in FrobeniusSolve

I have a knapsack problem. Say I have N possible items $x_i$. I would like to know: $ \sum_{i=0}^{2} c_i x_i = W$ With the following constraint: $c_i=3 \lor 4$ As an example suppose the set $x_i=...
9
votes
1answer
166 views

Modular equation problem

I have problem solving this modular equation $67^n \equiv 67 \pmod {317026939759222841944}$ with $n>1$. I have tried my Laptop and Wolfram Alpha engine, but I don't get any solution, I'm very ...
0
votes
1answer
66 views

List of PrimeFactors without powers

If I do FactorInteger[120] I get {{2, 3}, {3, 1}, {5, 1}} which is correct of course, but how do I get it as or change it ...
4
votes
1answer
391 views

Zeckendorf representation

Zeckendorf's theorem. Every positive integer $n$ can be expressed uniquely as a sum of distinct non-consecutive Fibonacci numbers Sequence of Fibonacci numbers which add up to $n$ is called the ...
2
votes
1answer
1k views

List of Coprimes

Is there a way to generate a list of parametrized length, say $L$, of integers which are relatively prime among them? I would like to take into account their word-length as well, so for example the ...
6
votes
1answer
112 views

Efficient way to sum all divisors of numbers below N excluding divisors 4/d

So, I want to Sum all divisors off all numbers below N (for a big N, i.e. N=10^16) which (divisors) are NOT a multiple of 4 I tried DivisorSigma but then the following method was x2 faster ...
2
votes
3answers
185 views

How to find all prime power factorizations of an integer

I want to put in $n$ and get the possible factorizations into prime powers. Let's say for 24 I want {{8,3}, {4,2,3}, {2,2,2,3}}. The algorithm for doing this on ...
0
votes
0answers
44 views

Randomly selected two integers are relatively prime [duplicate]

The probability that two integers $m$ and $n$ picked at random are relatively prime is $6/\pi^2$ There is a simple code to check it ...
3
votes
1answer
86 views

Problem with QPochhammer or SeriesCofficient?

In version 10.2.0, I calculated the number of integer partitions of n into exactly k distinct parts with no part exceeding ...
9
votes
1answer
449 views

Calculate $140$ digits of Conway's Constant from the Look and Say Sequence

The look-and-say sequence is the sequence of numbers $1, 11, 21, 1211, 111221, 312211, …,$ in which each term is constructed by “reading” the previous term in the sequence. For example, the term $1$ ...
13
votes
7answers
2k views

Finding vampire numbers

How to find vampire numbers by using Mathematica? A number $v=xy$ with an even number $n$ of digits formed by multiplying a pair of $n/2$-digit numbers (where the digits are taken from the ...
5
votes
2answers
126 views

Finding all solutions in the Roth's theorem

Roth's theorem. For all algebraic irrational $\alpha$ $$\displaystyle \left \lvert \alpha - \frac{p}{q} \right \rvert < \frac{1}{q^{2 + \epsilon}}$$ with $\epsilon>0$, has finitely many ...
3
votes
0answers
100 views

Wrong divergence message for the continued fraction

Bug introduced in 8.0.4 or earlier and fixed in 11.2 Why there is an error message for ContinuedFractionK[k, 1, {k, Infinity}]? It is well known that, this ...
3
votes
2answers
418 views

Expressing numbers as the sum of 2^(2^k) powers

I have a list of numbers and I want to express each one as an integer linear combination of $2^{(2^k)}$ powers. Some elements of the list are ...
5
votes
1answer
393 views

Algorithm for Egyptian fractions, want to optimize the maximum denominator size

Any rational number can be expanded into a finite sum of unit fractions with distinct denominators, called Egyptian fractions. There is no 'optimal' algorithm in terms of denominator size or number ...
4
votes
3answers
220 views

find and count the number of solutions without multiplicity in Solve?

I would like to solve a Diophantine equation and find its solution, but I need only count one time for each $a$, i.e., when for some $a$ it found some $x,y,z$, then go to the next $a$. more precisely ...
1
vote
0answers
67 views

Last digits via PowerMod [closed]

Do you have an idea why this produces different results? PowerMod[2003, 2002^2001, 1000] 241 ...
12
votes
1answer
461 views

SquaresR memory leak?

I have tried the following code in Mathematica 11.0.1.0 on my MacBook: ...
0
votes
0answers
28 views

How to solve equations in Gaussian integers modulo p efficiently [duplicate]

This question is related to my previous question which can be found here. Calling the function sols1 = gaussianPowerModList[I, 8192, 18446744069414584321];] ...
1
vote
1answer
271 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 ...
4
votes
1answer
135 views

Sum of squared digits returns incorrect result

For the sake of practicing writing code, I've given myself an exercise in writing a script that checks whether a given positive integer is happy, i.e. take the digits of a number, square them, and add ...
11
votes
2answers
1k views

Finding Ramanujan's taxicab numbers

How to find Hardy-Ramanujan Numbers by using Mathematica? Definition: Taxicab number is defined as the smallest number that can be expressed as a sum of two positive cubes in $n$ distinct ways. ...
0
votes
1answer
87 views

How to solve this problem in Mathematica?

Let's say we have some 4-character strings: fxhg eagc aceh chbe beca From those strings we want to get the correct passcode. Each of the string contains two ...
9
votes
2answers
674 views

Visualizing the primes with the Riemann Zeta function

I am trying to plot the identity seen here, namely that if we define: $$\psi _{0}(x)={\frac 12}\left(\sum _{{n\leq x}}\Lambda (n)+\sum _{{n<x}}\Lambda (n)\right)$$ Then, it equal to the following,...
0
votes
1answer
146 views

How to plot the number of Mersenne Primes lower than a given input?

I would like to plot the number of Mersenne primes (primes of the form $2^n-1$) lower than a given input. I am totally noob to mathematica and I do not know where to start from. I have tried to ...
3
votes
1answer
582 views

How does Mathematica compute how to write integers as the sum of k non-negative pth integer powers so quickly?

"PowersRepresentations[n,k,p] gives the distinct representations of the integer n as a sum of ...
1
vote
1answer
361 views

Some information about PrimeQ function

In Mathematica there is a built-in function called PrimeQ which tests given input as True or ...
5
votes
1answer
44 views

Speak stops on first Hyphen with IntegerName

IntegerName returns the text of an integer. However, when Speak is applied to the result it stops at the fist hyphen. For ...
0
votes
2answers
211 views

Powers of prime factors of a positive integer $n$ in “Mathematica”?

I would like to find the powers of a prime in the unique prime factorization of an $n$. I want a function $f[n,p]$ such that $n,p$ are given and I need to know what the power of $p$ is. For instance ...
0
votes
0answers
64 views

MultiplicativeOrder understanding

According to specification, this should find the smallest integer $m$ such that $10^m \, mod \, 16 = 0$, or return unevaluated if there is no such integer. ...
4
votes
4answers
298 views

Trying to find the numbers which could be shown in 3 different ways using Legendre's three-square theorem

Legendre's three-square theorem states that $n=a^{2}+b^{2}+c^{2}$ if and only if $n$ is not of the form $n = 4^a(8b + 7)$ for integers $a$ and $b$. There are numbers like 54 which can be ...
8
votes
2answers
1k views

Plotting the sum of two points on an elliptic curve

I am doing an experiment to prove the associativity of the addition of points on an elliptic curve. So far, I have produced a code which allows me to move points on my curve. To find their sum, I ...
19
votes
4answers
3k views

Find the 5566th digit after the decimal point of 7/101

I want to find the 5566th digit after the decimal point of 7/101. I input the following code into Mathematica 11: Mod[IntegerPart[7/101*10^5566], 10] The output ...
2
votes
1answer
97 views

What is the correct and conventional way to express the Dirichlet eta function as Dirichlet characters in Mathematica?

What is the correct and conventional way to express the Dirichlet eta function as Dirichlet characters in Mathematica? ...

1 2
3
4 5
7