Skip to main content
14 votes
Accepted

Making the number 12345...n

FromDigits@Flatten[IntegerDigits /@ Range[15]] 123456789101112131415 A function to do it: ...
murray's user avatar
  • 11.9k
12 votes
Accepted

Checking if a number is right sorted

f1 = OrderedQ @* Rest @* IntegerDigits; f1 /@ {51369, 51396} {True, False} ...
kglr's user avatar
  • 396k
10 votes

Making the number 12345...n

f1 = FromDigits @ StringRiffle[Range[#], ""] &; f1 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} ...
kglr's user avatar
  • 396k
9 votes

Is there a command that does exact numerical conversion of non-exact to exact numbers?

However, the only method I've found that ensures numerically exact conversion is the manual one: delete the decimal point, and then divide by 10^z, where z is the number of digits to the right of the ...
Szabolcs's user avatar
  • 235k
9 votes
Accepted

Exporting large numbers to .PDF file

One way would be to split the large number in smaller chunks, convert each of them to a string, which can be manipulated, and then exporting. ...
b.gates.you.know.what's user avatar
9 votes

How to plot a function with huge numbers?

Since we are dealing with very large numbers, so one of the option is to use ListLogPlot ...
zhk's user avatar
  • 11.9k
9 votes

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

NextPrime has no problems evaluating for large numbers well above $10^{14}$. I think it's safe to assume these are real prime numbers, for confirmation see the ...
rhermans's user avatar
  • 36.5k
8 votes

How to get the bit size (bit length) of an integer?

You can use BitLength or IntegerLength: BitLength[number] 4091 ...
kglr's user avatar
  • 396k
8 votes

Making the number 12345...n

Without using IntegerDigits or string processing: ...
flinty's user avatar
  • 25.3k
8 votes

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

The prime generator and the primality proving package both seem very quick at $10^{14}$: ...
Roman's user avatar
  • 47.5k
7 votes
Accepted

Using the solve function for big numbers, getting a failure now

Hmm, I just posted an answer yesterday that overcame just this problem with the undocumented option "SolveDiscreteSolutionBound" that controls a system limit: <...
Michael E2's user avatar
  • 236k
7 votes
Accepted

Efficiently checking whether a number is a perfect power

I offer the following as a fast way of testing cubic and higher powers primes = Select[Range[59], PrimeQ] Get a list of all the relevant powers up to a specified ...
mikado's user avatar
  • 16.8k
7 votes

Checking if a number is right sorted

f = AllTrue[Rest[Differences[IntegerDigits[#]]], Positive] & Test: f /@ {51369, 412345, 824699, 41395, 31832} True, True, ...
Syed's user avatar
  • 54.3k
6 votes

How to stop calculating if there're some large number?

Here's one way, using Carl Woll's suggestion of MemoryConstrained, which runs very quickly: ...
Michael E2's user avatar
  • 236k
6 votes
Accepted

Why $\pi$ // Rationalize does not give a rational multiple of $\pi$ in my example?

I want to show that without hypotheses, the problem of determining whether $x=a/\pi$ came from a rational number is unsolvable. But, spoiler alert, the OP's number ...
Michael E2's user avatar
  • 236k
5 votes

Efficiently checking whether a number is a perfect power

There is this way: ...
Coolwater's user avatar
  • 20.3k
5 votes

Making the number 12345...n

ToExpression[ StringJoin[ ToString /@ Range[15] ] ]
David Reiss's user avatar
5 votes

Making the number 12345...n

For fun, here's some more options, which are quite distinct from the already existing ones. First, a recursive definition: ...
AccidentalFourierTransform's user avatar
5 votes

Making the number 12345...n

Timings for all the methods (g1 : murray, g2 : flinty, g3/g4 : AccidentalFourierTransform, g5/g6 : Syed, g7 : David Reiss, g8 : user1066, g9/g10/g11 : kglr) posted so far: ...
kglr's user avatar
  • 396k
5 votes

Performance regression for big integer computation

I think the best you can do, is to compile a function for BigInts with FunctionCompile. The compilation is slow, but the execution is fast: ...
Sjoerd Smit's user avatar
  • 23.5k
4 votes
Accepted

Solving an equation in integers giving an error message

This uses less memory: ...
Michael E2's user avatar
  • 236k
4 votes
Accepted

Using Parallelize in a solve function

You want $10^{13}\leq y\leq 10^{14}$, so obviously $10^{26}\leq y^2\leq 10^{28}$. The range of $x$ for which your expression $10^{26}\leq y^2 = 2213326116 + 94098\ x\ (1 + x) (-31363 + 31366\ x)\leq ...
MarcoB's user avatar
  • 67.2k
4 votes

Using the solve function for big numbers, getting a failure now

Here's a direct search using a fast square test from this answer: ...
Roman's user avatar
  • 47.5k
4 votes

Plot for big x numbers

Might I suggest not making a plot like that? Whatever information that you are trying to get across will likely be clearer if you plot with x-values relative to $10^{15}$ and note that in the axes ...
Simon Rochester's user avatar
4 votes

How to loop through a large number in mathematica

How many (not-necessarily-prime) factors of $200!$ are there? First, get all the prime factors. (The maximum such factor will be less than $200$, of course--in fact it is $199$.) ...
David G. Stork's user avatar
4 votes

Making the number 12345...n

Identical to the solution by @murray but written as a composition: f = FromDigits@* Flatten@* IntegerDigits@* Range@ # & f /@ Range[8, 15] ...
Syed's user avatar
  • 54.3k
4 votes

Checking if a number is right sorted

A slight variation on the method given by @kglr 51369//IntegerDigits[#,10,IntegerLength[#]-1]&//OrderedQ (* True *)
user1066's user avatar
  • 18.3k
4 votes
Accepted

How can I make sure that the two given numbers are exactly the same?

Code (explanation below) n2[[1 ;; 3]]*n2[[4]] == n2 (* True *) ...
userrandrand's user avatar
  • 5,882
3 votes

Integrate over sharp peak

mu = 105660000; mtau = 1776860000; GeV = 1000000000; Use exact numbers when defining tmpfuncc, i.e., ...
Bob Hanlon's user avatar
  • 158k
3 votes

How to prevent spikes in memory usage during simple numerical evaluation?

Just put N as early as possible to avoid symbolic computations: MaxMemoryUsed[N[Abs[Tanh[Power[N@E, Power[N@Pi, N@E]]]]]] ...
Henrik Schumacher's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible