Created
July 11, 2017 14:08
-
-
Save Chelsea486MHz/b781c268ce59500d83193968c850aa66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint64_t o1_add(const uint64_t a, const uint64_t b); /* Implemented */ | |
| uint64_t o2_mul(const uint64_t a, const uint64_t b); /* Implemented */ | |
| uint64_t o3_exp(const uint64_t a, const uint64_t b); /* Implemented */ | |
| uint64_t o4_tet(const uint64_t a, const uint64_t b); /* Implemented */ | |
| uint64_t order_n(const uint64_t n, const uint64_t a, const uint64_t b); | |
| uint64_t o1_add(const uint64_t a, const uint64_t b) | |
| { | |
| uint64_t res; | |
| res = a; | |
| for (uint64_t i=0; i<b; ++i) | |
| ++res; | |
| return (res); | |
| } | |
| uint64_t o2_mul(const uint64_t a, const uint64_t b) | |
| { | |
| uint64_t res; | |
| res = 0; | |
| for (uint64_t i=0; i<b; ++i) | |
| res = o1_add(res, a); | |
| return (res); | |
| } | |
| uint64_t o3_exp(const uint64_t a, const uint64_t b) | |
| { | |
| uint64_t res; | |
| res = 1; | |
| for (uint64_t i=0; i<b; ++i) | |
| res = o2_mul(res, a); | |
| return (res); | |
| } | |
| uint64_t o4_tet(const uint64_t a, const uint64_t b) | |
| { | |
| uint64_t res; | |
| res = a; | |
| for (uint64_t i=0; i<b; ++i) | |
| res = o3_exp(res, a); | |
| return (res); | |
| } | |
| uint64_t order_n(const uint64_t n, const uint64_t a, const uint64_t b) | |
| { | |
| uint64_t res; | |
| if (n <= 1) | |
| return (a+b); | |
| res = 0; | |
| for (uint64_t i=0; i<b; ++i) | |
| res = order_n(n-1, res, a); | |
| return (res); | |
| } | |
| int main(void) | |
| { | |
| printf("2*60 = %Ld\n", o2_mul(2, 60)); | |
| printf("24*4 = %Ld\n", o2_mul(24, 4)); | |
| printf("10*0 = %Ld\n", o2_mul(10, 0)); | |
| printf("2^10 = %Ld\n", o3_exp(2, 10)); | |
| printf("2^^4 = %Ld\n", o4_tet(2, 4)); | |
| putchar('\n'); | |
| printf("O(1, 10, 4) = %Ld\n", order_n(1, 10, 4)); | |
| printf("O(2, 10, 4) = %Ld\n", order_n(2, 10, 4)); | |
| printf("O(3, 10, 4) = %Ld", order_n(3, 10, 4)); | |
| return (EXIT_SUCCESS); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment