Find the sum of following series using methods in java program:
1+1/2+1/3+1/4+1/5
Answers
Answered by
4
public class Series
{
public static void main(String args[ ])
{
int a;
for(a=1;a<=5;a++)
{
s = s + 1/a;
}
System. out. println(" The sum of the series= " +a);
}
}
{
public static void main(String args[ ])
{
int a;
for(a=1;a<=5;a++)
{
s = s + 1/a;
}
System. out. println(" The sum of the series= " +a);
}
}
Kunal777:
pls mark my answer as brainliest
Answered by
2
class Sumofseries
{
public static void main(String args[ ])
{
int a;
for(a=1;a<=5;a++)
{
s = s + 1/a;
}
System. out. println(" The sum of the series= " +a);
}
}
{
public static void main(String args[ ])
{
int a;
for(a=1;a<=5;a++)
{
s = s + 1/a;
}
System. out. println(" The sum of the series= " +a);
}
}
Similar questions