Need help for this project Please!

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1546 Views - Last Post: 21 March 2009 - 08:53 AM Rate Topic: -----

#16 scottyadam   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 116
  • Joined: 03-December 07

Re: Need help for this project Please!

Posted 20 March 2009 - 03:49 PM

no problem dude,

make sure you know what is going on here. The code that I first created is to be modified (as you can tell) to be "correct" based on the following posts. If you don't know what is going on...we're here to help out.
Was This Post Helpful? 0
  • +
  • -

#17 priya_lorha   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 82
  • Joined: 02-August 08

Re: Need help for this project Please!

Posted 21 March 2009 - 08:53 AM

1> generate prime nos
2> find the square of the Prime nos
3> divide the square of the Prime nos by one
4> add one to it
5> store it in the variable and keep on multiplying with the proceeding sum












Hey modify the programme accroding to your requirement

class primesum{
static void main(int n){//n here is the no of prime nos
int a=1,b,c,k=1;
double sum=1;
System.out.print("The product of the series((1+1/2^2)+(1+1/3^2)........)is:");
do{c=0;
for(b=2;b<a;b++)
{if(a%b==0)
c=1;}
if(c==0)
{
double p=1+1/Math.pow(a,2);
sum*=((int)(1+p));
k++;}
a++;
}while(k<=n);
System.out.println(sum);
}
}
  

This post has been edited by priya_lorha: 21 March 2009 - 08:56 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2