Register FAQ Search Today's Posts Mark Forums Read

 2011-06-30, 23:16 #1 LiquidNitrogen     Jun 2011 Henlopen Acres, Delaware 7×19 Posts Primes in a spreadsheet When searching around for a soft copy of primes on the internet, pickings are surprisingly scarce. You come across text lists with no particular alignment specifications and comma separated lists with other info embedded, so there's a bunch a data cleansing that needs to be done. Does anyone have an Excel spreadsheet with just one column with a bunch of primes, one in each row?
 2011-06-30, 23:49 #2 Christenson     Dec 2010 Monticello 70316 Posts See Here: http://www.mersenneforum.org/showthread.php?t=15705 Since you aren't (yet) interested in particularly large primes, the very basic 10-line program being discussed there should work fine for you, and you can ask it for any alignment you like. Just import the result into your spreadsheet. And be careful not to overwhelm the spreadsheet; there are 60,000 or so primes under 10^6.
 2011-07-01, 00:44 #3 lavalamp     Oct 2007 Manchester, UK 2×5×137 Posts Here's some more basic code for Pari/gp: Code: \\default(primelimit,10^7); \\ The default is only 500,000. Maximum value is 4,294,965,247. Uncomment the start of the line and set appropriately as needed. output_file="C:/primes.csv"; \\ Where do you want your primes? start_prime=2; \\ Does not need to be prime, it will start from the first prime after this value. end_prime=10^3; \\ Also does not need to be prime, it will stop at the last prime before this value. { forprime(p=start_prime,end_prime, write(output_file,p); ); } Just copy that into a text file then you can run it by typing something like this in Pari: Code: \r drive:/path/to/file.txt By default it will output primes from 2 to 1000 as a CSV file on your C: which can be directly opened by Excel. Note that if the file already exists, it will add to it, not overwrite it. You can download Pari/gp from here.
 2011-07-01, 00:46 #4 Uncwilly 6809 > 6502     """"""""""""""""""" Aug 2003 101×103 Posts 246268 Posts There are some prime generators around. Some are allow you to pick a starting point and the number to generate. FWIW, it will be faster to generate them than to have excel save them. here is one simple one: http://javaboutique.internet.com/prime_numb/ Last fiddled with by Uncwilly on 2011-07-01 at 00:50
 2011-07-01, 04:10 #5 CRGreathouse     Aug 2006 135358 Posts I'll add another vote for PARI/GP (make sure to download the "Windows binary" if you're running Windows). Here's how I'd code it: Code: makePrimes(howMany, file)={ if(default(primelimit) < howMany, default(primelimit, howMany)); forprime(p=2,howMany,write(file, p)) }; makePrimes(100000, "c:/location.csv")
2011-07-01, 11:33   #6
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts

Quote:
 Originally Posted by CRGreathouse I'll add another vote for PARI/GP (make sure to download the "Windows binary" if you're running Windows). Here's how I'd code it: Code: makePrimes(howMany, file)={ if(default(primelimit) < howMany, default(primelimit, howMany)); forprime(p=2,howMany,write(file, p)) }; makePrimes(100000, "c:/location.csv")
thank's for the code is there a way to list them across the top as well to create a multiplication chart ?

2011-07-01, 17:55   #7
lavalamp

Oct 2007
Manchester, UK

101010110102 Posts

Quote:
 Originally Posted by science_man_88 thank's for the code is there a way to list them across the top as well to create a multiplication chart ?
The write() function includes a line break at the end, the write1() function does not.

2011-07-01, 22:00   #8
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts

Quote:
 Originally Posted by lavalamp The write() function includes a line break at the end, the write1() function does not.
tried it and nothing appeared in the complete spreadsheet.

2011-07-01, 23:31   #9

"Richard B. Woods"
Aug 2002
Wisconsin USA

170148 Posts

Quote:
 Originally Posted by science_man_88 tried it and nothing appeared in the complete spreadsheet.
Might it be that one needs to do at least one write() after all the write1()s are issued?

2011-07-01, 23:47   #10
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

203108 Posts

Quote:
 Originally Posted by cheesehead Might it be that one needs to do at least one write() after all the write1()s are issued?
It might! Trying that now. Thanks for the suggestion.

2011-07-01, 23:51   #11
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts

Quote:
 Originally Posted by science_man_88 It might! Trying that now. Thanks for the suggestion.
doesn't work at last check. took out one thing first to try. I still haven't found a way that seems to work.

Last fiddled with by science_man_88 on 2011-07-01 at 23:53

 Similar Threads Thread Thread Starter Forum Replies Last Post carpetpool Miscellaneous Math 4 2022-07-14 02:29 emily Math 34 2017-07-16 18:44 Mickey1 Miscellaneous Math 1 2013-05-30 12:32 Unregistered Information & Answers 0 2011-01-31 15:41 troels munkner Miscellaneous Math 4 2006-06-02 08:35

All times are UTC. The time now is 23:05.

Thu Aug 18 23:05:23 UTC 2022 up 20:33, 0 users, load averages: 1.52, 1.34, 1.32