![]() |
|
|
|
|
1
2nd July 16:07
External User
Posts: 1
|
For example,
a:=convert(evalf[1000](exp(1)),string): for n from 3 do p:=parse(a[n..(n+9)]); if isprime(p) then print(p); break fi od: 7427466391 Alec Mihailovs http://math.tntech.edu/alec/ |
|
|
|
|
3
2nd July 16:07
External User
Posts: 1
|
Also, it can be done "in one line", similar to Mathematica,
select(isprime,[seq(parse(sprintf("%a",evalf[200](exp(1)))[n..(n+9)]), n=3..191)])[1]; 7427466391 Alec Mihailovs http://math.tntech.edu/alec/ |
|
|
4
2nd July 16:07
External User
Posts: 1
|
|>news:200501051421.j05ELdOY044563@ns.mccme.ru...
|>> Puzzle is to find the first 10-digit prime number occurring in consecutive |>> digits (i.e., the decimal expansion) of the e. Answer is known |>> (7427466391), it was found using the following Mathematica code: |>For example, |>a:=convert(evalf[1000](exp(1)),string): for n from 3 do |>p:=parse(a[n..(n+9)]); if isprime(p) then print(p); break fi od: Another way, a bit more like the Mathematica code: [n..(n+9)]),n=3..900))[1]; Of course, this is a lot less efficient than Alec's code, but still takes only 0.751 seconds on my rather slow computer. Robert Israel israel@math.ubc.ca Department of Mathematics http://www.math.ubc.ca/~israel University of British Columbia Vancouver, BC, Canada |
|