473,385 Members | 1,798 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 find prime of Big integer number?

I want to find all the prime number less then some given big integer number.

like

BigInteger n=new BigInteger(jTextField1.getText());
then all prime number less then n.

While I tried it was giving error the increment and comparison operator can not be applied to BigInt..

Expand|Select|Wrap|Line Numbers
  1. for (i=1;i<n; n.add(BigInteger.ONE)) // Error : -- and >= can not be applied to java.math.BigInteger
  2. {
  3.  
  4. int ctr=0;
  5. for(x =i; x>=1; x--) // Error : -- and >= can not be applied to java.math.BigInteger
  6. {
  7. if(i%x==0) //Error : % can not be applied to java.math.BigInteger
  8. {
  9. ctr = ctr + 1;
  10. }
  11. }
  12. if (ctr ==2)
  13. {
  14. System.out.print(" " + i);
  15. }
  16.  
  17. }
Any solution to this?
Feb 3 '13 #1
1 2593
Luuk
1,047 Expert 1GB
Out of pure interest, i google for the answer ;)
it seems to be here: http://stackoverflow.com/questions/1...use-biginteger

There is a long way to go before you hit the jackpot:
http://www.reuters.com/article/2013/...9170UO20130208
Feb 9 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Olly | last post by:
Find an id number not present in a linking table I have a linking table (tblPayment) that monitors the subscriptions from members. However, I need a query that can compare the ID number fields...
12
by: Klaus Drechsel | last post by:
My Problem: The Function Dispose on a IDisposable shuld be called on the last reference to this instance. Can I get the number of references. to an object? Klaus Drechsel
4
by: Mahesh BS | last post by:
Hello, I need to write a query to find out a set of missing number in a given sequence. Eg : a Column in some table has the following data
10
by: svlsr2000 | last post by:
Can any one give me best algorithm to find nth ugly number.
1
by: Simon | last post by:
Dear reader, Is there a function or VBA code available to find the week number out of a date field. You can find the year with Year(date field) but now I need the week number out of a...
2
by: rajukotla | last post by:
How to find out the number of days in a financial year. suppose from date is sep1st,2006.and to date is aug24th,2009. the entire range involves financial years.i.e., ...
2
by: Revathi Balakrishnan | last post by:
Hi All Is it possible to find out the number of frames the page contain? For example my page is divided in to three frames using frameset tag, and one of my frame has i frame also. Like such...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.