Creative Commons License Foxbond's Repo

/** (c) 2015 Michał (Foxbond) Chraniuk */
#include <stdio.h>

int sum(int m, int n){
		if (n<m){
			 return 0;
	  }
	  return n+sum(m, n-1);
}

int main (){
		int n,m;
		printf("Podaj m: ");
		scanf("%d", &m);
		do {
			 printf("\nPodaj n (wieksze/rowne od %d): ", m);
		   scanf("%d", &n);
	  }while(n<m);
		printf("\nSuma liczb z przedzialu <%d,%d> = %d\n", m, n, sum(m, n));
		getch();
		return 0;
}

> Back