# Accenture Coding Question 10 ## Coding Question 10

You are required to implement the following function, Int Calculate(int m, int n);

The function accepts 2 positive integer ‘m’ and ‘n’ as its arguments.You are required to calculate the sum of numbers divisible both by 3 and 5, between ‘m’ and ‘n’ both inclusive and return the same.

Note:

0 < m <= n

Example

Input:

m : 12

n : 50

Output:

90

Explanation:
The numbers divisible by both 3 and 5, between 12 and 50 both inclusive are {15, 30, 45} and their sum is 90.

Sample Input
m : 100
n : 160
Sample Output
405

`/* Programming Question */#include <stdio.h>int Calculate(int, int);int main(){int m, n, result;// Getting Inputprintf("Enter the value of m : ");scanf("%d",&m);printf("Enter the value of n : ");scanf("%d",&n);result = Calculate(n,m);// Getting Outputprintf("%d",result);return 0;}/* Write your code below . . . */int Calculate(int n, int m){// Write your code hereint i, sum = 0;for(i=m;i<=n;i++){if((i%3==0)&&(i%5==0)){sum = sum + i;}}return sum;}`
`#include<iostream>using namespace std;int Calculate(int, int);int main(){int m, n, result;// Getting Inputcout<<"Enter the value of m :";cin>>m;cout<<"Enter the value of n :";cin>>n;result = Calculate(n,m);// Getting Outputcout<<result;return 0;}/* Write your code below . . . */int Calculate(int n, int m){// Write your code hereint i, sum = 0;for(i=m;i<=n;i++){if((i%3==0)&&(i%5==0)){sum = sum + i;}}return sum;}`
`import java.util.Scanner;public class Main {	int sum=0;	int Calculate(int m, int n){        for (int i = m; i < n; i++)           if((i%3==0) && (i%5==0))               sum = sum+i;           return sum;    }		public static void main(String[] args) {		    	        Scanner sc = new Scanner(System.in); 	        System.out.println("Enter the value of m and n");	        int m =  sc.nextInt();	        int n = sc.nextInt();	        Main q = new Main();	        int result = q.Calculate(m,n);	        System.out.println(result); 	}}`
```m = int(input("M:"))
n = int(input("N:"))

def calculate(m, n):
sum = 0
for i in range(m,n+1,1):
if i%3 == 0 and i%5 == 0:
sum = sum + i
print(sum)

calculate(m,n)```