diff options
author | zedarider <ymherklotz@gmail.com> | 2016-02-18 11:37:45 +0000 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2016-02-18 11:37:45 +0000 |
commit | af98ee7ff28cff97f5f29a5d9e65f9153531b0ee (patch) | |
tree | 86bfc53a0bc04512ac2936ee067a2b43e901e688 /TriangularDivisor.cpp | |
download | imperial_2015-af98ee7ff28cff97f5f29a5d9e65f9153531b0ee.tar.gz imperial_2015-af98ee7ff28cff97f5f29a5d9e65f9153531b0ee.zip |
Imperial C++ Directory
These are all the projects I’ve been working on at university.
Diffstat (limited to 'TriangularDivisor.cpp')
-rw-r--r-- | TriangularDivisor.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/TriangularDivisor.cpp b/TriangularDivisor.cpp new file mode 100644 index 0000000..4e1278c --- /dev/null +++ b/TriangularDivisor.cpp @@ -0,0 +1,29 @@ +#include <iostream> + +using namespace std; + +int main() { + int count, triangle, k, result; + int* allcount = new int[100000000000]; + k = 0; + result = 1; + for(int i = 2; i < 50000; ++i) { + triangle = (i*(i+1))/2; + int realtriangle = triangle; + for(int j = 2; j <= triangle; ++j) { + count = 0; + while(triangle % j == 0) { + triangle /= j; + ++count; + } + allcount[k] = count; + ++k; + } + for(int j = 0; j < k; ++j) { + result *= (allcount[j]+1); + } + if(result > 500) { + cout << realtriangle << endl; + } + } +}
\ No newline at end of file |