2
$\begingroup$

Here's my problem, I want to take what I have now for code

 N[
   Sum[2/10^((n*(Floor[9/n] + 1) - 9)4), {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[ 2/(10^((n(Floor[9/n] + 1) - 9)4) (10^(n*4) - 1)), 
     {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[2/(10^((o^2 - o - 9)* 4)*(10^(o*4) - 1)), 
     {o, Floor[Sqrt[9]] + 1, 10}], 
   ((10 + 1)^2 - 9)* 4];
AbsoluteTiming[Flatten[
   Position[Partition[RealDigits[%][[1]], 4, 4, -1], {(0) .., 2}]]] + 9

and seperate it into two operations. I've read the documentation and it's helped me figure out how to write a file, but I've tried and have not been able to import the file for processeing during the second part without displaying some junk. I've successfully been able to do this,

N[
   Sum[2/10^((n*(Floor[9/n] + 1) - 9)4), {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[ 2/(10^((n(Floor[9/n] + 1) - 9)4) (10^(n*4) - 1)), 
     {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[2/(10^((o^2 - o - 9)* 4)*(10^(o*4) - 1)), 
     {o, Floor[Sqrt[9]] + 1, 10}], 
   ((10 + 1)^2 - 9)* 4] >> "testdd9-10"

and I have verified the file using

FilePrint["testdd9-10"]

but I have been unsucessful with the second part. I've tried,

Import["testdd9-10"];
AbsoluteTiming[Flatten[
   Position[Partition[RealDigits[%][[1]], 4, 4, -1], {(0) .., 2}]]] + 9

This will be absolutely necessary for me to figure out how to do so that I may process large ranges of primes and sort out formats of numbers which are prime, like safe primes. I have a 6TB hard drive and I'm just itching to fill it.

$\endgroup$
  • 1
    $\begingroup$ << "testdd9-10";, and seeing as you write testdd9-10 but are trying to import testdd9-20, PBCAK... $\endgroup$ – ciao Mar 28 '15 at 23:02
  • $\begingroup$ @rasher a typo, I will fix $\endgroup$ – user24719 Mar 28 '15 at 23:15
  • 1
    $\begingroup$ no,no the problem is not the typo . the problem is that the escape character splits the large number into sublists. see my solution below $\endgroup$ – penguin77 Mar 28 '15 at 23:22
2
$\begingroup$

Easy fix:

Export the result in the form ExpressionML
Here is the code.

 N[
   Sum[2/10^((n*(Floor[9/n] + 1) - 9)4), {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[ 2/(10^((n(Floor[9/n] + 1) - 9)4) (10^(n*4) - 1)), 
     {n, 1, Floor[Sqrt[ 9]]}] + 
   Sum[2/(10^((o^2 - o - 9)* 4)*(10^(o*4) - 1)), 
     {o, Floor[Sqrt[9]] + 1, 10}], 
   ((10 + 1)^2 - 9)* 4] // Export["testdd9-10", #, "ExpressionML"] &

Hint: For trouble shooting use

Import["testdd9-10"] // InputForm  

but run your code without // InputForm to get a result you can use.

(PS: a 6Tb disk?, I am jealous,hi,hi,hi)

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Import["testdd9-10"] //ImputForm ImputForm - is that some new/undocumented feature? ;-) $\endgroup$ – ciao Mar 28 '15 at 23:20
  • $\begingroup$ I think he means InputForm with an n instead of an m $\endgroup$ – user24719 Mar 28 '15 at 23:25
  • $\begingroup$ Sorry for typo, I have corrected. my fingers are freeeezing... $\endgroup$ – penguin77 Mar 28 '15 at 23:27
  • $\begingroup$ @penquin77,This does not yield the intended result. Import["testdd9-10"] // InputForm AbsoluteTiming[Flatten[ Position[Partition[ RealDigits[%][[1]], 4, 4, -1], {(0) .., 2}]]] + 9 $\endgroup$ – user24719 Mar 28 '15 at 23:39
  • $\begingroup$ @penquin77, Wait a minute, yes it does. BUT, it displays the decimal output afterward, that which I'm hoping to avoid displaying when I begin to deal with larger ranges $\endgroup$ – user24719 Mar 28 '15 at 23:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.