Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX 1000
- static void print(char *v1, char *v2, size_t size) {
- for (size_t i = 0; i < size; ++i) {
- printf("%d", v1[i]);
- }
- puts("");
- for (size_t i = 0; i < size; ++i) {
- printf("%d", v2[i]);
- }
- puts("");
- }
- int main(void) {
- char a[MAX] = {1, 0}, b[MAX] = {0}, c[MAX] = {0};
- c[0] = -1; // dummy
- for (int m = 1; memcmp(b, c, sizeof b); ++m) {
- // print(a, b, MAX);
- memcpy(c, b, sizeof c);
- for (size_t i = 0; i < MAX; ++i) {
- b[i] += a[i];
- for (size_t j = i; 1 <= j && 9 < b[j]; --j) {
- b[j] -= 10;
- ++b[j - 1];
- }
- }
- for (int i = 0, p = 0; i < MAX;
- p *= 10, p += a[i], a[i] = p / m, p %= m, ++i) {
- ;
- }
- }
- printf("%d.", b[0]);
- for (size_t i = 1; i < MAX; ++i) {
- printf("%d", b[i]);
- }
- puts("");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement