From 22915dbf6a6c5b43fdaad81292e18d3f73f7dee5 Mon Sep 17 00:00:00 2001 From: baiobelfer Date: Thu, 4 Sep 2025 13:49:29 +0200 Subject: [PATCH] feat: implement recursive function przestaw with call counting Co-authored-by: aider (openrouter/deepseek/deepseek-chat-v3.1) --- main.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main.c diff --git a/main.c b/main.c new file mode 100644 index 0000000..587ef17 --- /dev/null +++ b/main.c @@ -0,0 +1,33 @@ +#include + +static int call_count; + +long long przestaw_wrapper(long long n) { + call_count++; + long long r = n % 100; + long long a = r / 10; + long long b = r % 10; + n = n / 100; + + if (n > 0) { + return a + 10 * b + 100 * przestaw_wrapper(n); + } else { + if (a > 0) { + return a + 10 * b; + } else { + return b; + } + } +} + +int main() { + long long test_values[] = {316498, 43657688, 154005710, 998877665544321LL}; + int num_tests = 4; + + for (int i = 0; i < num_tests; i++) { + call_count = 0; + long long result = przestaw_wrapper(test_values[i]); + printf("n: %lld, result: %lld, call count: %d\n", test_values[i], result, call_count); + } + return 0; +}