Skip to content

Instantly share code, notes, and snippets.

@sjchmiela
Created November 4, 2013 17:41
Show Gist options
  • Save sjchmiela/7306373 to your computer and use it in GitHub Desktop.
Save sjchmiela/7306373 to your computer and use it in GitHub Desktop.
//
// 29-10-2013.cpp
// wdi2013
//
// Created by Stanisław Chmiela on 29.10.2013.
// Copyright (c) 2013 Stanisław Chmiela. All rights reserved.
//
#include <cstdio>
using namespace std;
const int max = 51;
int main() {
int e[max], factorial[max], current;
bool end = 0;
for(int i = 0; i<max; i++) {
e[i] = factorial[i] = 0;
}
factorial[0] = 1;
e[0] = 1;
current = 1;
while(!end) {
int r = 0;
for(int i = max; i>=0; i--) {
e[i] = e[i] + r + factorial[i];
r = e[i]/10;
e[i] = e[i]%10;
}
current++;
r = 0;
for(int i = 0; i<max; i++) {
r = 10*r + factorial[i];
factorial[i] = r/current;
r = r%current;
}
end = 1;
for(int i = 0; i<max; i++) {
if(factorial[i] != 0) {
end = 0;
break;
}
}
}
printf("%d.",e[0]);
for(int i = 1; i<max; i++) {
printf("%d",e[i]);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment