import java.io.*;
class nsumfact
{
public static void main (String args[]) throws IOException
{
int fact, sum, i, n;
fact=1;
sum=0;
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br =new BufferedReader(ir);
System.out.println("Please Enter the value of N");
n=Integer.parseInt(br.readLine());
System.out.println("N Natural Numbers are =");
for(i=1;i<=n;i++)
{
System.out.println("\n Natural Numbers="+i);
sum=sum+i;
fact=fact*i;
}
System.out.println("\n Factorial of Last Number is ="+fact);
System.out.println("\n The Sum of the N Numbers is="+sum);
}
}
class nsumfact
{
public static void main (String args[]) throws IOException
{
int fact, sum, i, n;
fact=1;
sum=0;
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br =new BufferedReader(ir);
System.out.println("Please Enter the value of N");
n=Integer.parseInt(br.readLine());
System.out.println("N Natural Numbers are =");
for(i=1;i<=n;i++)
{
System.out.println("\n Natural Numbers="+i);
sum=sum+i;
fact=fact*i;
}
System.out.println("\n Factorial of Last Number is ="+fact);
System.out.println("\n The Sum of the N Numbers is="+sum);
}
}
No comments:
Post a Comment