You are on page 1of 1

/*

* 40 - Champernowne's Constant.cpp
*
* Author: tempo
*/
#include <iostream>
#include <sstream>
#include <string>

int main(){ // twelfth index is the first 1


std::string fraction;
for (int i = 0; i < 10000000; i++){
std::string num = std::to_string(i);
fraction += num;
// std::cout << fraction << std::endl;
if (fraction.length() > 1000000){
// std::cout << fraction;
break;
}
}

int nums[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, aa, bb, cc, dd, ee, ff, gg;
int chars[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
char a = fraction[1], b = fraction[10], c = fraction[100], d =
fraction[1000], e = fraction[10000], f = fraction[100000], g = fraction[1000000];

for (int i = 0; i < 10; i++){


if (a == chars[i])
aa = nums[i];
if (b == chars[i])
bb = nums[i];
if (c == chars[i])
cc = nums[i];
if (d == chars[i])
dd = nums[i];
if (e == chars[i])
ee = nums[i];
if (f == chars[i])
ff = nums[i];
if (g == chars[i])
gg = nums[i];
}

std::cout << aa*bb*cc*dd*ee*ff*gg;

You might also like