fork download
  1. #include <stdio.h>
  2.  
  3. int sum(int n,int m){
  4. if(n==m){
  5. return m;
  6. }else{
  7. return n+sum(n-1,m);
  8. }
  9. }
  10.  
  11. int main(void){
  12. int a,b;
  13. printf("aはb以上の数を入れてください\n");
  14. scanf("%d %d",&a,&b);
  15. if(a>b){
  16. printf("%d",sum(a,b));
  17. }else{
  18. printf("aはb以上の数を入れてください\n");
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5292KB
stdin
6 3
stdout
aはb以上の数を入れてください
18