java - Riemann hypothesis prime number theorem -
so working on riemann hypothesis prime number theorem,
loop in method isprimenumber
, loop okay because tested on separate class , worked well.. primes
text area. problem here wanted info appended in text area once enter number in field, want when input 100, gives me primes numbers 1-99, giving me numbers 10,000 - prime numbers. appreciated. working well.. tried debugging couldn't locate problem, still learning more on debugging.
public void run() { int quantity = integer.parseint(field.gettext()); int primenumbers = 0; int allnumbers = 2; primes.append("this prime numbers in " + quantity + " riemann hypothesis "); while(primenumbers<quantity){ if(isprimenumber(allnumbers)){ primes.append(allnumbers + " "); primenumbers++; } allnumbers++; }
you're algorithm giving first 100 prime numbers (which run 541, not 10000). if want prime numbers 1 100 instead, change
while(primenumbers<quantity){
to
while(allnumbers<quantity){
Comments
Post a Comment