Sum of the multiples of two numbers below N | Java program to find the sum of all the integers below N which are multiples of either A or B ; Function to return the sum of all the integers below N which are multiples of either A or B ; If i is a multiple of a or b ; Driver code
import java . io . * ; class GFG { static int findSum ( int n , int a , int b ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( i % a == 0 i % b == 0 ) sum += i ; return sum ; } public static void main ( String [ ] args ) { int n = 10 , a = 3 , b = 5 ; System . out . println ( findSum ( n , a , b ) ) ; } }