C 6
Lab10 By zlax on 7th December 2024 04:55:57 PM
  1. #include <stdio.h>
  2.  
  3. long int func(long int, long int);
  4.  
  5. int main(void) {
  6.     long int n,m;
  7.     scanf("%ld", &n);
  8.     scanf("%ld", &m);
  9.     printf("%d\n", func(n, m));
  10.     return 0;
  11. }
  12.  
  13. long int func(long int n, long int m) {
  14.         if (n == 1) return m;
  15.     else if (n%2 == 0) return (n / 2);
  16.         else return func(((n + 1) / 2), (m + 1));
  17. }

Paste is for source code and general debugging text.

Raw Paste

Login or Register to edit or fork this paste. It's free.