MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Product of the first 1000th Prime


(* We do it step by step, in the knowledge that there is almost certainly a
better way! *)

(*Create a table of the first 1000 primes *)
t=Table[Prime[i], {i, 1000}];

(* Generate their product *)
p=Apply[Times, t];

(* Express the result in hexadecimal, but it will be a list containing 10,
11, 12, 13, 14, 15, 16 *)

 hex=IntegerDigits[p,16];

(* Replace the digits by their appropriate character codes, and then form
the string from them *)
hexString=FromCharacterCode[
  h /. {0 -> 48, 1 -> 49, 2 -> 50, 3 -> 51, 4 -> 52, 5 -> 53, 6 -> 54,
      7 -> 55, 8 -> 56, 9 -> 57, 10 -> 65, 11 -> 66, 12 -> 67, 13 -> 68,
      14 -> 69, 15 -> 70}];

Now you just need to write out the string by whatever method you would
normally want.

Have I just passed a homework assignment?!

Cheers,



--
Mark R Diamond
Vision Research Laboratory
The University of Western Australia
no spam email: markd at psy dot uwa dot edu dot au




  • Prev by Date: Re: Mathematica and 3D surface.
  • Next by Date: Re: Mathematica and 3D surface.
  • Previous by thread: Re: Product of the first 1000th Prime
  • Next by thread: Fixed Time Step for NDSolve