mersenneforum.org  

Go Back   mersenneforum.org > New To GIMPS? Start Here! > Information & Answers

Reply
 
Thread Tools
Old 2011-06-30, 23:16   #1
LiquidNitrogen
 
LiquidNitrogen's Avatar
 
Jun 2011
Henlopen Acres, Delaware

7×19 Posts
Default 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?
LiquidNitrogen is offline   Reply With Quote
Old 2011-06-30, 23:49   #2
Christenson
 
Christenson's Avatar
 
Dec 2010
Monticello

70316 Posts
Default

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.
Christenson is offline   Reply With Quote
Old 2011-07-01, 00:44   #3
lavalamp
 
lavalamp's Avatar
 
Oct 2007
Manchester, UK

2×5×137 Posts
Default

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.
lavalamp is offline   Reply With Quote
Old 2011-07-01, 00:46   #4
Uncwilly
6809 > 6502
 
Uncwilly's Avatar
 
"""""""""""""""""""
Aug 2003
101×103 Posts

246268 Posts
Default

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
Uncwilly is online now   Reply With Quote
Old 2011-07-01, 04:10   #5
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135358 Posts
Default

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")
CRGreathouse is offline   Reply With Quote
Old 2011-07-01, 11:33   #6
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
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 ?
science_man_88 is offline   Reply With Quote
Old 2011-07-01, 17:55   #7
lavalamp
 
lavalamp's Avatar
 
Oct 2007
Manchester, UK

101010110102 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
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.
lavalamp is offline   Reply With Quote
Old 2011-07-01, 22:00   #8
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts
Default

Quote:
Originally Posted by lavalamp View Post
The write() function includes a line break at the end, the write1() function does not.
tried it and nothing appeared in the complete spreadsheet.
science_man_88 is offline   Reply With Quote
Old 2011-07-01, 23:31   #9
cheesehead
 
cheesehead's Avatar
 
"Richard B. Woods"
Aug 2002
Wisconsin USA

170148 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
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?
cheesehead is offline   Reply With Quote
Old 2011-07-01, 23:47   #10
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203108 Posts
Default

Quote:
Originally Posted by cheesehead View Post
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.
science_man_88 is offline   Reply With Quote
Old 2011-07-01, 23:51   #11
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

23×1,049 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
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
science_man_88 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mersenne Primes p which are in a set of twin primes is finite? carpetpool Miscellaneous Math 4 2022-07-14 02:29
Distribution of Mersenne primes before and after couples of primes found emily Math 34 2017-07-16 18:44
Conjecture about Mersenne primes and non-primes v2 Mickey1 Miscellaneous Math 1 2013-05-30 12:32
A conjecture about Mersenne primes and non-primes Unregistered Information & Answers 0 2011-01-31 15:41
possible primes (real primes & poss.prime products) 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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔