Menu
Question Index
...

Write a program to find the sum of the numbers divisible by 5 or 7 till a given number.

Input (Integer) Output (Integer)
50 5 + 7 + 10 + 14 + 15 + 20 + 21 + 25 + 28 + 30 + 35 + 40 + 42 + 45 + 49 + 50 = 436
NOTE: Although 35 is divisible by 5 and 7, it should added only once
15 5 + 7 + 10 + 14 + 15 = 51



class SumOfNumbersDivisibleByFiveAndSeven
{
    public static void main(String s[])
    {
        System.out.println("Sum of matched numbers till 50 is " + sum_of_matched_numbers(50));

    }


    public static int sum_of_matched_numbers(int input)
    {
        int output = 0;
        return output;
    }

}

Doubts

Problems

Topic: for Loop In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App