//WAJP to print 1 to 10.
class PrintingNumbers
{
public static void main()
{
int a=1;
while(a<=10)
{
System.out.print(a);
a=a+1;
}
}
}
//WAJP to print all Odd Numbers from 1 to 10.
class NumbersOdd
{
public static void main()
{
int a=1;
while(a<=10)
{
System.out.print(a);
a=a+2;
}
}
}
//WAJP to print all Even Numbers from 1 to 10.
class NumbersEven
{
public static void main()
{
int a=2;
while(a<=10)
{
System.out.print(a);
a=a+2;
}
}
}
//WAJP to print 1 to 10 in Reverse.
class ReverseNumbers
{
public static void main()
{
int a=10;
while(a>=1)
{
System.out.print(a);
a=a-1;
}
}
}
//WAJP to print the Sum of Natural Numbers. ( s = 1 + 2 + 3 + 4 + 5)
// Output: (The sum is 15)
class SumOfNaturalNumbers
{
public static void main()
{
int a=1, s=0;
while(a<=5)
{
System.out.print(a);
s = s + a;
a = a + 1;
}
System.out.print("The Sum of Natural Numbers "+s);
}
}
//WAJP to print to find the Factorial of any number. (!4=4 x 3 x 2 x 1)
// Output: (The Factorial is 24)
class Factorial
{
public static void main()
{
int a=1, f=1;
while(a<=5)
{
System.out.print(a);
f = f * a;
a = a + 1;
}
System.out.print("The Factorial is "+f);
}
}