Questions tagged [number-theory]

Questions on the number-theoretic functionality of Mathematica.

Filter by
Sorted by
Tagged with
0
votes
0answers
32 views

Division algorithm problem that need to be solved by using procedure [on hold]

My problem is; Write a procedure which finds the quotient and remainder of the division algorithm applied to two integers a and b. How can I use Floor to solve ...
21
votes
8answers
3k views

Fastest square number test

What is the fastest possible square number test in Mathematica, both for machine size and big integers? I presume starting in version 8 the fastest will be a dedicated C LibraryLink function.
0
votes
0answers
65 views

Integral Cuboid Problem [migrated]

Any progress in solving the integral cuboid problem?: Find a "brick" of integral dimensions a, b, c such that the 3 face-centered diagonals based on (a,b), (b,c), (...
4
votes
2answers
380 views

Drawing a sequence of circles

For every natural number from 1 to 150, draw a circle centered on the x-axis in that number and with the diameter equal to the number of divisors of the number. I don't know what should I do.
0
votes
1answer
51 views

Recurrence involving a product of recurrents

I can solve the following recurrence problem as follows: ...
-1
votes
0answers
77 views

Does such prime $P$ exist? [migrated]

The equation $(10^{6n+1}-54n-10)($mod P$) = 0$ , find the value of prime P such that there are AT LEAST 3 solutions for n > 0 , whose values of n are all below (P-1)/6. I don't even know how to solve ...
3
votes
2answers
176 views

solve for two variables for each n related to Collatz conjecture

For this code, for each x I would like to solve for all value ranges for c1 and c2 in a bounded range ie c1 and c2 in the range of real numbers +-100 for c1 and c2 for each x, which combined give "...
-1
votes
1answer
170 views

automatic formula finding function [duplicate]

I am curious how easy it would be to automatically find some formulas related to basic number theory OEIS sequences using some Mathematica search algorithm for a small set of OEIS sequences as a ...
9
votes
6answers
656 views

How can I plot a Farey diagram?

How can I plot the following diagram for a Farey series?
15
votes
2answers
427 views

Factor a polynomial Root into Roots of smallest possible degree

Suppose I have a polynomial Root representing an algebraic number. I want to represent it as a product of several polynomial Root...
1
vote
1answer
136 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 ...
2
votes
1answer
39 views

Prime factorization related functions: prime factor to its power and power of prime [duplicate]

FactorInteger can be used to perform prime factorization: FactorInteger[5^2 7^3 11^4] Results in: ...
4
votes
2answers
112 views

Generating numbers palindromic in two number bases

The purpose of the code below is to generate numbers that are $2d+1$ digit palindromes in number base $b+1$, and are also palindromic in number base $b+3$, where: The ...
8
votes
1answer
198 views

Using Mathematica to find an alternative continued fraction for $\zeta(5)$

Given the Riemann zeta function $\zeta(n)$. I. $x=\zeta(3)$ Using Euler's continued fraction formula, we can form $\zeta(3)$'s cfrac as, $$Ax+B = \cfrac{1}{v_1 - \cfrac{1^6}{v_2 - \cfrac{2^6}{...
5
votes
1answer
42 views

Abelianness-forcing number Q

In the theory of finite abstract group, abelianness-forcing number $n$ is characterized as a positive integer with standard factorization $n=p_1^{k_1}p_2^{k_2}\cdots p_r^{k_r}$ with $k_i \le 2$ and $...
12
votes
2answers
624 views

Ulam's Spiral with Oppermann's Diagonals (quarter-squares)

First we craft a function to return the quadrant boundary based on Oppermann's Conjecture a[n_] := (Mod[n, 2] + n^2 + 2 n)/4 Then we create a few lists ...
10
votes
1answer
209 views

How to calculate $\displaystyle \prod_{p}\frac{p^2+1}{p^2-1}$?

When I input $$ \prod _{p=2}^{\infty } \text{If}\left[\text{PrimeQ}[p],\frac{p^2+1}{p^2-1},1\right] $$ in Mathematica 12.0, it gives out the value $1$. The result is ridiculous, for that according to ...
2
votes
0answers
35 views

FindEquationalProof to prove divisor theorem

I'm trying to implement proofs of concepts for Equational Proofs on some basic number theory theorems. One such example is: "let a and b be positive integers and let d = gcd (a, b). If t divides ...
0
votes
2answers
44 views

Running a loop to check for multiple congruences

I have the code for a loop to run. Right now it can check if a number is a square and at the same time check if it is congruent 0 mod 47. My questions is, how can I alter the code to see if it is ...
3
votes
1answer
104 views

Number theory in Mathematica

Is there any book out there similar to S. Wagon's Mathematica in Action that has problems/exercises/projects in the field of number theory as done in Mathematica? If not pure number theory, at least ...
6
votes
3answers
357 views

How to do this Padovan spiral using Mathematica?

how to do this unusual pendovan spriral? can anyone help me ?
34
votes
8answers
32k views

Even Fibonacci numbers

Today, I found the Euler Project. Problem #2 is Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: ...
0
votes
2answers
200 views

Request code for creating sequences [closed]

I would like to have Mathematica code for creating the following sequence shown as rows: ...
0
votes
1answer
34 views

Expanding integer compositions

Quick version: I would like Mathematica code that, for instance, turns {3,1,2} into {3,3,3,1,2,2}. More formally, given positive integers $c_1, \ldots, c_t$ which sum to $n$, produce the length $n$ ...
0
votes
5answers
94 views

Sum Over Solutions to an Equation

Two Related Questions Is there any general built-in functionality for computing a sum over solutions to an equation? This is common in number theory. For example, computing sums of the following form....
0
votes
1answer
39 views

Reverse the reccurence mirrorwise

Let be a recurrence for polynomials $R_{m,j}$ ...
2
votes
2answers
127 views

Displaying the number of repeating digits in a fraction

I would like to check how many repeating digits are in a large fraction, I manually did it for the first few, but the repeating length is too large to manually check. ...
2
votes
6answers
4k views

A question regarding 1 divided 243 [closed]

Here is a problem due to Feynman. If you take 1 divided by 243 you get 0.004115226337 .... It goes a little cockeyed after 559 when you're carrying out the decimal expansion, but it soon straightens ...
7
votes
2answers
782 views

Approximation to the prime counting function

Is there a function similar to PrimePi that gives approximate value for large numbers? In particular, I need a reasonably good approximation for $\pi(x)$, where $x\...
2
votes
1answer
163 views

Rewrite the power sum in terms of convolution

Let be an identity $$n^{2m+1}=\sum_{r=0}^{m}A_{m,r}\sum_{k=0}^{n-1}k^r(n-k)^r,$$ where $A_{m,r}$ are real coefficients, see A302971 for numerators and formula of $A_{m,r}$. Here we can notice that $\...
4
votes
1answer
868 views

Why does Solve lock up when trying to solve the quadratic equation with large integers?

Why does Solve lock up when trying to solve the equation ...
24
votes
3answers
571 views

Speeding up the built-in Rudin-Shapiro and Thue-Morse sequence functions

Version 10.2 introduced two well-studied sequences as functions: the (Golay-)Rudin-Shapiro sequence (RudinShapiro[]) and the (Prouhet-)Thue-Morse sequence (...
0
votes
0answers
64 views

Most efficient way to define evil and odious numbers [duplicate]

A positive integer $n$ is defined to be evil if the number of ones in its binary expansion is even, otherwise it is odious. Now define the function $$ \begin{equation*} t(n)= \begin{cases} 1 \rm{ \...
8
votes
3answers
789 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,\...
2
votes
1answer
81 views

My version of PowerMod breaks down around 10^308

I have been trying to write a function that duplicates PowerMod[a, b, n], computing a^b mod n...
3
votes
1answer
174 views

Table of Chebyshev psi function

This should be easy, but for some reason I'm struggling. The Chebyshev psi function is given as the sum from 0 to x of the von ...
3
votes
1answer
78 views

List of invertible congruence classes

I am attempting to create a list of the invertible congruence classes $\bmod 120$. The code I have is ...
34
votes
2answers
8k views

Trying to visualize the Collatz conjecture

I happen to have this collatz collatz[x_, y_] := If[x == 3*y || x == 2*y + 1 || y == 3*x || y == 2*x + 2, 2, 0] So i want a visual 3D adjacency graph of my ...
1
vote
2answers
60 views

Using a Do-loop to find divisors mod 13 [closed]

I want to check sum of divisors of i mod 13 fori = 1 to i = 20. I tried writing a Do-Print ...
2
votes
1answer
94 views

Mathematica code for computing the $p$-adic expansion of rational numbers

Does anyone know any Mathematica code for computing the $p$-adic expansion of rational numbers? I.e. given a rational number $a/b,~a,b\in \mathbb{Z}$ and a prime number $p$, then compute the $p$-adic ...
6
votes
1answer
85 views

Computing the seven roots of a polynomial

This question was originally asked by @fsrong70 six months ago. The OP deleted it shortly after posting and has not returned to this site since. I had just figured it out when it was deleted. I ...
5
votes
0answers
100 views

Not comprehending PowerMod

Bug introduced in 10.3 or earlier and persisting through 11.3.0 or later The bug is not present in 10.0. By definition, PowerMod[a, 1/r, m] finds a modular rth root of a mod m. Here's a pair of ...
0
votes
1answer
70 views

What is the best build-in function to pick or select given element in a huge list

im looking for a best and efficient function works like a search engine it takes for example m=5+6I ,then it goes searching in the list V={1,1+I,2+3I,...} until catch it . My Dr said to use "Select[]"...
3
votes
2answers
815 views

Determining if a number is divisible by 1000 [closed]

I have a number such as: a = 875952; And I want to find if it is divisible by 1000. Is there a concise way of doing that?
4
votes
3answers
368 views

Generate numbers relatively prime with a given number

I am interested in a function such that f[m, i] = n where m, n are positive integers and n ...
0
votes
0answers
74 views

Find the maximum of a function involved with Floor function

My function is $$ f(H,p) = \left\lfloor \dfrac{\lfloor H/p\rfloor + 3 - \sqrt{(\lfloor H/p\rfloor + 1)^2 - 4H}}{2} \right\rfloor $$ The constraints are $ H \geq p(4p-1) $, $ p $ is prime although ...
6
votes
4answers
1k 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 ...
7
votes
2answers
321 views

Efficient code for minimum integer with given number of factors

I'm seeking an efficient implementation of the number-theoretic function giving the smallest integer $n$ that has exactly $k$ factors (not necessarily prime): ...
6
votes
2answers
149 views

Finding $x$, the exponent of a $2^x$ when we need an specific output

Say we need a program Findx[n_Integer, m_Integer] where n is an integer from 1 to 9 and m is an integer from 1 to 1000. The output of the program is a number x, which is the exponent of 2 that ...
-5
votes
1answer
146 views

Solving Diophantine equations 5 [closed]

Given a positive integers x,y,m would like to be able to find integer solutions z from Diophantine equation x^2-y^2 = m*z in Z. ---The proof,is divided in 4 sections---... x=2*k+1 ,y=2*h+1 with ...