473,840 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prime Numbers

Hello!

I have been doing some research to see if C++ has some sort of
function to work with prime numbers.

For example, I would like to input integers and have the program check
to see if the integers are prime numbers.

I have been unsuccessful in finding anything. I am sure I can probably
figure out a long way to do it, but I was curious to see if C++ had
something available.

Thanks!
Chris
Jul 19 '05 #1
4 11511
"Chris" <de*****@verizo n.net> wrote...
I have been doing some research to see if C++ has some sort of
function to work with prime numbers.

For example, I would like to input integers and have the program check
to see if the integers are prime numbers.

I have been unsuccessful in finding anything. I am sure I can probably
figure out a long way to do it, but I was curious to see if C++ had
something available.


The Standard library does NOT have such a function. If it did,
all those seekers of the largest number would have nothing to
do, would they?

Try www.google.com.

Victor
Jul 19 '05 #2
In article <2e************ *************@p osting.google.c om>,
de*****@verizon .net says...
Hello!

I have been doing some research to see if C++ has some sort of
function to work with prime numbers.
None that's particular to prime numbers, and not really much that's any
more than a building-block toward working with large numbers in general.
For example, I would like to input integers and have the program check
to see if the integers are prime numbers.
Depending on how big of numbers you want to deal with, that's anywhere
from trivial (e.g. < 20 digits) to a massive project (e.g. the General
Number Field Sieve is one of the most complex algorithms ever devised by
man).
I have been unsuccessful in finding anything. I am sure I can probably
figure out a long way to do it, but I was curious to see if C++ had
something available.


The MIRACL library has quite a nice factoring program as a free demo of
its capabilities. You can get the library (with the demo) from:
ftp://ftp.computing.dcu.ie/pub/crypto/miracl.zip

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #3

"Jerry Coffin" <jc*****@taeus. com> wrote in message
news:MP******** *************** *@news.clspco.a delphia.net...
In article <2e************ *************@p osting.google.c om>,
de*****@verizon .net says...
Hello!

I have been doing some research to see if C++ has some sort of
function to work with prime numbers.


None that's particular to prime numbers, and not really much that's any
more than a building-block toward working with large numbers in general.
For example, I would like to input integers and have the program check
to see if the integers are prime numbers.


Depending on how big of numbers you want to deal with, that's anywhere
from trivial (e.g. < 20 digits) to a massive project (e.g. the General
Number Field Sieve is one of the most complex algorithms ever devised by
man).
I have been unsuccessful in finding anything. I am sure I can probably
figure out a long way to do it, but I was curious to see if C++ had
something available.


The MIRACL library has quite a nice factoring program as a free demo of
its capabilities. You can get the library (with the demo) from:
ftp://ftp.computing.dcu.ie/pub/crypto/miracl.zip

--
Later,
Jerry.


Not to forget the nice "Miller Rabin probabilistic primality" test, which
IMHO is just a piece of art.

Cheers
Chris
Jul 19 '05 #4

Not to forget the nice "Miller Rabin probabilistic primality" test, which
IMHO is just a piece of art.

Yes.
Rabin's work was based on randomized algorithms.
It shows how sometimes randomized algorithms solve problems much more easily
over their deterministic counterparts.


Jul 19 '05 #5

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

Similar topics

36
8417
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, but a prime number tester would also be nice. I'm dealing with numbers in the 10^6-10^8 range so it would have to fairly efficient Dag
9
2718
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 (testPrimes.py) with two algorithms that both check for primes by testing only odd numbers using factors up to the square root of the value, where Primes1 is based on all of the existing primes so far, and Primes2 is based on all odd numbers, I would...
11
7166
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 the exact code ( well maybe a little) but the logic or algorithm to tell whether or not a number is prime....
0
2406
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 been made by A & A Group. Muhammad Ali: Roll # 1462 Class A-2 , B.Sc.(Hons.) in C.S.
0
1736
by: ETM11871 | 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 complicated. we are on a functions chapter. i am usung the square root to find the prime. so far i have accomplished this but i cant fgure how to divide this by ten so i can find the right prime. i am using c. #include <stdio.h> #include <math.h> ...
25
3897
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 complicated. we are on a functions chapter. i am usung the square root to find the prime. so far i have accomplished this but i cant fgure how to divide this by ten so i can find the right prime. i am using c. #include <stdio.h>
60
1950
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 ending in 5 ..which obviously cannot be prime numbers) can anyone please help me out with the reason?? /*Generate Prime Numbers*/ #include<stdio.h>
7
4910
by: newstips6706 | last post by:
1, 2, 3, 5, 7... PRIME Numbers ________________________________ Definitions What is a PRIME Number ?
7
4140
by: Caffiend | last post by:
Well, I've been picking at learning python, got tired of reading, and figured I'd try to replicate my prime number generator I wrote (with much TSDN forum help) in C++. I've hit a stumbling block... the program is supposed to print onscreen all the prime numbers between two numbers given to it, so if I put in 1 and 10, it should print out 1, 3, 5, 7 (I know, technically 1 isn't considered prime, and 2 should be on there, but otherwise...) ...
0
10603
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10301
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9440
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7838
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7023
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4076
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3138
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.