1234567891011121314151617#include #include void main() { double input = pow(2, 1); int sum = 0; int i = 0; while ((int)(input / pow(10, i)) != 0) ++i; for (int j = i - 1; j >= 0; --j) { sum += (int)(input / pow(10, j)); input = fmod(input, pow(10, j)); printf("%d\t%f\n", sum, input); if (input == 0) break; } printf("%d\n", sum);}Colored by Color Scriptercs 이와 같이 하면 2^1000처럼 큰 숫자에서는 정확한 답이 나오지 않는..
1234567891011121314151617181920212223242526272829#include #include void main() { double input; int tempInput = 0; int count = 0; int temp = 0; int i; for (i = 1000000; i >= 1; --i) { input = i; for (;;) { if (fmod(input, 2) == 0) input /= 2; else input = input * 3 + 1; ++count; if (input == 1) { if (temp
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970#include double Function(int arr[][20]) { double result1 = 0, result2 = 0, result3 = 0, result4 = 0; for (int i = 0; i