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.
16 Replies - 1546 Views - Last Post: 21 March 2009 - 08:53 AM
#17
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
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

New Topic/Question
Reply



MultiQuote


|