Thursday, January 9, 2014

Print the number which is divided by 5 and 7 between 0 to n numbers.

import java.util.*;
class Num5o7
{
    public static void main(String surat[])
    {
        Scanner s=new Scanner(System.in);
        System.out.print("Enter the number: ");
        int n=s.nextInt();
        for(int i=0;i<n;i++)
        {
            if(i%7==0 && i%5==0)
                System.out.println(i);
        }
    }
}

Output:

No comments:

Post a Comment