Advertisement
josiftepe

Untitled

Nov 27th, 2022
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int suma_na_cifri(int broj) {
  4.     if(broj == 0) {
  5.         return 0;
  6.     }
  7.     int cifra = broj % 10;
  8.     int dodadi = 0;
  9.     if(cifra % 2 == 1) {
  10.         dodadi = cifra;
  11.     }
  12.     return suma_na_cifri(broj / 10) + dodadi;
  13. }
  14. void rekurzija(int a, int b) {
  15.     if(a > b) {
  16.         return;
  17.     }
  18.     int sum = suma_na_cifri(a);
  19.     if(sum != 0 && sum % 5 == 0) {
  20.         printf("%d ", a);
  21.     }
  22.     rekurzija(a + 1, b);
  23. }
  24. int main(){
  25.     int A, B;
  26.     scanf("%d%d", &A, &B);
  27.     rekurzija(A, B);
  28.     return 0;
  29.  
  30. }
  31.  
  32. /*
  33.  **/
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement