From 4fc79e56cde83a4da2ab73933e7fd7ad5f4111e0 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 19 Jul 2022 20:28:33 +0000 Subject: [PATCH] Start preparing the generation process for iterations Co-authored-by: sigonasr2 --- current | Bin 21280 -> 17136 bytes src/main.c | 89 ++++++++++++++++++++++++----------------------------- 2 files changed, 40 insertions(+), 49 deletions(-) diff --git a/current b/current index edfb57ce8524f06590d4f7365bb5a524e0ed4767..eb1ff498eff7d91549a049adb5413dab04a6d55c 100755 GIT binary patch delta 3312 zcmZ`+eQ;A%7Qgo;fuum2v-3X+yR1+B z9^sGDgRcK)xtm+=28&^I%$nJXuL_s(NiEx!);7I{~U?()D+!wSbDG|HS~n!D+V5iT0+bP%ONxW`xo$BjkwB~6MNjkFw&Np_&7TcO?* zG7|~^2r^*=)p0kON%X!OZQNC7{DNkp~|IU)X%98()C7-Q=Vq4jkrMbABy-N-(Vc;Fc z-KdT?P<1MT;(6=@_L@FpaQjS;BM>${%lf!|i#nd?>|>ih#S!(7X!#CaUR8{q~$y)^}n=2R?xU@O+F_x_%!G1|rEo&|g5^{~8D|HUP%g6bNhnE{PYLA` zJNkr@VuzDZrZBxpSeXhbABB}vNSO*NABB`uLK#8cN4}B6%1B^;xM|l|=rlSN#Lyha z5t8)dW(SlJI`HI(<*C1GTp-*&(;2wcu5Gi&l+3*zt8n;@Qh_D5t@t}C{pSjFmE0?} zU4h|}da33LTrX*tu73;dr8UyuzK!iEwNmN*>DY^9CMvx<1&5ZuA{9@;UCtxrtkCGo zHeF`Rj?=I*Uay?n`SxE}(kF8-gF_xDPht>swF8qGYJb+%wok%IxwqzN=75$;{-1By z>piuc5dW6u&|m%S&7o=k&-|ge_Q2lCH<7-3!!6hF49v;AiP%<`jShN@!HQ0qcu2(~ zofcAo51}Q7`fX@$F?&*~`U2ukL>9n3h+iOHLS(C+olw;*jhj+@9Lul2cOrF??4o-6gzwHIgb|4FjC32J|i_QSs=Z)cp;|93Z#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;6hlc@>IEZ2I4z6>b#I2tQNu zwv^Ju{@#S|tn$h*DC@(!OSekWDi~Yquo450$8iX(E{AnUXdH83qsw86axDr$SBcre zi->2?sB5KF98Ci8-&L7U+6P@_j_z^`M9Q4jV-{^JfxE$4?wI;>D@qoyz^3v-vp8mO zTO2GevG5fYE87BNrMWO(ZZV7F#p48X#Y(d{RiaLK0#)%pt=$C&Q5Bz6rwc|=6(>iJ z3(W47Q)g~_xi-&M*ywhe#0poyL3fGJEEO>7E|)66ysq3>p}DVujq6HGt?M;y6uQ=x M$m^bf(RB;{2ZePGApigX diff --git a/src/main.c b/src/main.c index beb7bf9..07578a5 100644 --- a/src/main.c +++ b/src/main.c @@ -1,63 +1,54 @@ #include #include "utils.h" -#include /* - A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. + A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: - A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. + 012 021 102 120 201 210 - As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. + What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? - Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. - - https://projecteuler.net/problem=23 + https://projecteuler.net/problem=24 */ -int main(int argc,char**argv) { - //First find all abundant numbers. - //Then iterate through all abundant numbers and determine which numbers are made with them. Numbers not found are to be summed together. - int*abundantNumbers=malloc(sizeof(int)*0); - int abundantNumberCount=0; - for (int i=1;i<=28123;i++) { - int factorSum=1; - //Iterate through divisors. - int max=i/2; - for (int j=2;ji) { - //printf("%d is abundant...\n",i); - abundantNumbers=realloc(abundantNumbers,sizeof(int)*(++abundantNumberCount)); - abundantNumbers[abundantNumberCount-1]=i; - } +void generate(int*a,int count,boolean useNextHighest) { + for (int i=0;i<10;i++) { + int*newArr=malloc(sizeof(int)*(count+1)); + newArr[i]=i; + generate(newArr,count+1,true); + generate(newArr,count+1,false); } - //Next is to sum up all integers up to 28124. - long sum=0; - for (int i=0;i<28124;i++) { - sum+=i; - } - printf("Sum of all numbers is %ld\n",sum); +} - boolean removed[28124] = {}; - - for (int i=0;i