473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to generate prime numbers

can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....

Mar 26 '07 #1
4 7544
On Mar 26, 8:48 am, ritesh.raghuvan...@gmail.com wrote:
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....
This sounds like homework to me. On this group, we don't usually
answer homework questions directly, but help you to work the answer
out for yourself.

So, how far have you got already? What's not working?

Jon

Mar 26 '07 #2
On 26 Mar 2007 00:48:12 -0700, ri****************@gmail.com wrote:
>can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....
Look up the Sieve of Eratosthenes.

rossum

Mar 26 '07 #3
ri****************@gmail.com wrote:
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....
Funny, I did the same just the other day. It's quite easy.

First of all, you can't start from zero, you have to start from one.

Just loop throught the numbers from one to the entered number. Store the
prime numbers in a list, and loop throught the list for each number
checking if any of them is evenly dividable by the number.

--
Göran Andersson
_____
http://www.guffa.com
Mar 26 '07 #4
Google for [ "Prime Number" testing ]...

try http://www.voidware.com/primetest.htm

....

<ri****************@gmail.comwrote in message
news:11*********************@y66g2000hsf.googlegro ups.com...
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....

Mar 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Dag | last post by:
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N,...
9
by: Greg Brunet | last post by:
In doing some testing of different but simple algorithms for getting a list of prime numbers, I ended up getting some results that seem a bit contradictory. Given the following test program...
11
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not...
0
by: AshifToday | last post by:
this was my and my frineds little project in earlier classes, the program seperates the composite and prime numbers in two sections of the screen ===================== /* This program has...
12
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's...
25
by: johnmsimon | last post by:
i need to develop a code that finds a prime right number between 2 and 100000. and print one line of text that indicates if the int. is right prime. i am in beginning programing so complex is...
60
by: rhle.freak | last post by:
Here is my code to generate prime numbers.It works absolutely fine when the range is *not very large*. However on initializing i with a large integer it produces erroneous results (some numbers...
7
by: newstips6706 | last post by:
1, 2, 3, 5, 7... PRIME Numbers ________________________________ Definitions What is a PRIME Number ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.