26
votes
Accepted
Find the 5566th digit after the decimal point of 7/101
Fast algorithm
n = 5566
IntegerPart[10 Mod[7 PowerMod[10, n - 1, 101], 101]/101]
A brute force approach (see also these posts on stackoverflow :) ) may
be fine ...
25
votes
Accepted
InverseTotient[ ]?
Perhaps:
Reduce`EulerPhiInverse[6]
(* {7, 9, 14, 18} *)
Not sure why such things are hidden & undocumented, perhaps because it's available through ...
20
votes
Transform a number to a factorial
An example target, a bit over half-a-million digits:
x = 123456!;
IntegerLength@x
574965
Results for target, and a non-hit:
...
19
votes
Accepted
19
votes
Digits of Pi in colored spiral
At first we define the Archimedean spiral in parametric form
a := 0;
b := 0.3;
r[t_] := a + b t;
x[t_] := r[t]*Cos[t];
y[t_] := r[t]*Sin[t];
Next, generate a list ...
18
votes
Accepted
SquaresR memory leak?
Cause
Under the hood System`SquaresR is still calling functions in the context NumberTheory`.
Partial output of:
...
17
votes
16
votes
François Viète's approximation to π
You could use
VietePiApprox[n_] := (Times @@ NestList[Sqrt[2 + #] &, Sqrt[2], n])/ 2^(n + 1)
SetAttributes[VietePiApprox, Listable]
which approximates Pi as ...
16
votes
Does Mathematica have a twin prime equivalent of `PrimePi`?
If you need all the primes that are twin primes up to n then.
...
15
votes
How can I plot a Farey diagram?
The curvilinear triangles which are characteristic for this type of plot are called hypocycloid curves. We can use the parametric equations on Wikipedia to plot these, like so:
...
15
votes
Transform a number to a factorial
Stirling's approximation, $n! \sim n^ne^{-n}$, is the Swiss army knife of factorial problems. If $x = n!$, this implies that $\ln x \sim n \ln n - n$; and surprisingly this can be solved with a ...
14
votes
Accepted
14
votes
14
votes
Accepted
Making the number 12345...n
FromDigits@Flatten[IntegerDigits /@ Range[15]]
123456789101112131415
A function to do it:
...
13
votes
Accepted
Elliptic curve cryptography in Mathematica
A few updates, since Wolfram has added a lot of cryptography functionality in recent versions.
Here is a link to the guide page for Cryptography functions in the Wolfram Language:
https://reference....
13
votes
Accepted
Factor a polynomial Root into Roots of smallest possible degree
A constructive approach
The problem can be solved if the form of the solution is given.
Define the two factors using a hint (that these should be cubic equations) in the original post
...
13
votes
Accepted
Plotting the sum of two points on an elliptic curve
Here's a starting point:
...
13
votes
Calculate $140$ digits of Conway's Constant from the Look and Say Sequence
I call this ambiguous and I think you haven't thought this through. Let us assume it would be possible by such a direct method of calculating $\lambda$. First, we need to speed up the high-level ...
13
votes
Accepted
Zeckendorf representation
Here's a greedy algorithm, using results from here:
...
13
votes
Accepted
Drawing a sequence of circles
Graphics[
{r = Length[Divisors@#]/2;
ColorData["Rainbow"][(r - 1)/7],
Circle[{#, 0}, r]} & /@
Range[150],
ImageSize -> 504]
12
votes
Accepted
Sum a number's digits until only one digit remain
Clear[s, t, n]
t[n_] := NestWhileList[Total[IntegerDigits[#]] & , n, # > 10 &]
Test:
t[649134976]
{649134976, 49,...
12
votes
Accepted
Checking if a number is right sorted
f1 = OrderedQ @* Rest @* IntegerDigits;
f1 /@ {51369, 51396}
{True, False}
...
11
votes
Some information about PrimeQ function
Source: https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.html
PrimeQ first tests for divisibility using small primes, then uses the Miller–Rabin strong ...
11
votes
First two n such that $1355297$ divides$10^{6n+5}-54n-46$ for $n>0$
There is no need for a brute force search. There is also no need for compilation, which may run into the maximum compiled integer limit. A faster solution follows from a bit of theory. You can get the ...
11
votes
Accepted
Computing the seven roots of a polynomial
poly = x^7 + x^6 - 18 x^5 - 35 x^4 + 38 x^3 + 104 x^2 + 7 x - 49;
Find an extension in which the polynomial splits:
...
11
votes
Accepted
Mathematica code for computing the $p$-adic expansion of rational numbers
Something like this code should work:
...
11
votes
Accepted
The integer ababab (a,b>0) is always divisible by 7, without remainder
One may regard this question as the test of the system ability of proving theorems, but there is another view to understand what lies beneath this theorem.
Then we figure out that the problem is quite ...
11
votes
11
votes
All solutions that satisfy $ x_{1}^{5}+x_{2}^{5}+x_{3}^{5}+x_{4}^{5}-x_{5}^{5}=0 $
I am a bit surprised that not a Mathematica solution with a statement "I don't think Mathematica is suited for this kind of problem." is accepted. I do believe that Mathematica is well ...
10
votes
Find the 5566th digit after the decimal point of 7/101
An alternative formulation of RealDigits that I prefer:
RealDigits[7/101, 10, 1, -5566][[1, 1]]
(* 6 *)
This yields better ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
number-theory × 454prime-numbers × 65
equation-solving × 50
list-manipulation × 46
performance-tuning × 44
special-functions × 28
number-representation × 25
functions × 21
modular-arithmetic × 21
function-construction × 20
factorization × 20
combinatorics × 19
big-numbers × 19
diophantine-equations × 18
summation × 17
plotting × 16
parallelization × 14
code-request × 14
partitions × 14
calculus-and-analysis × 12
programming × 12
code-review × 12
algorithm × 10
implementation-details × 10
recursion × 9