From a0bc12a775273df46e0fb8aa07c86d7986b77c52 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Fri, 15 Jul 2022 14:16:39 +0000 Subject: [PATCH] Co-authored-by: sigonasr2 --- archives/10/current | Bin 0 -> 16824 bytes archives/10/src/main.c | 31 +++++++++++++++++++++++++++++++ archives/10/src/utils.h | 7 +++++++ current | Bin 16696 -> 16824 bytes src/main.c | 38 +++++++++++++++++++------------------- 5 files changed, 57 insertions(+), 19 deletions(-) create mode 100755 archives/10/current create mode 100644 archives/10/src/main.c create mode 100644 archives/10/src/utils.h diff --git a/archives/10/current b/archives/10/current new file mode 100755 index 0000000000000000000000000000000000000000..d5b5ef4a840c616c465f120765cc67ca1cb902e1 GIT binary patch literal 16824 zcmeHOYitzP6~4R6!@SlDfyO|CCnQMF)Qe5QHK`nSjn|AL^C;L2RRiO-cWke;53@TP z?4%APPEl5l8`K|dezdClBPvy?1X5KIsY;A!ApOx4nyR8nA0!Iux{%bkp>o^6_MAKC zEHmSEk)r%+=UThxp6|TwJ@?M+T+h8nB5f^Rk4JFviAMx-;{g*1kzjf&Re*#gqTMO7J4JR(Cn+9N z&L`#sKMj;mCsja(MUme^IPLb6os%|`K2wZ=W#3gJ_DSOHA-hgRx)DywahP(vFM}No zt!a3dZyx5o6mPb1=%oBJrSyu8iFjB2=8cJ1O(LGk4b%)Y)YsH+4rbHAO)@gJ3uEA% z+OexcfSYl|D2;L~mJ^Tiq3LzMef!4!FCRO-|JOh5TJ~!HIp1sS17o5N7PRLnfjrh1 zzz22A{yzgX6GM7Qe=~`6wz3xlN*UoAz?PN4m(GG$&4O>91y2F4z{gn@0Z=aP5a5ba z8TfVZSz87dFh1Ql9QC3n-LI!aej{;^8qk>Y)Zy0IA0qmdBcM9 zHIDd23y!|r;%30jfSUm~18xS~47eF^Gw|tV;O~`d{-q9IuTV$k{(hqn>Nmy>Z}Fl! z{ELcnGEi~Lvj9&O*9`-ytQM%>hmxs@cZge2MNVZNJE1>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UCEe8Lo&T7%zfap#q`xCmM$AS&D^>yWy@L)(>i)J#>K}}B?nL*K$i6(U|mP;lF z!NkI8plR4t@%RWdNz+>PhIdA^$gXA$&V|_ZVnS>F>aOt4*6ntQJb(faocYlrDtSGtS9=Wj}^09jm!R%nth;{)rGA8Zg8XOnWGyNi%N*j8xH63OBXZ7|~uK)%&8^J`s!!rXYk#jf^RILeFI5>6DGpK$g)HQ8b`h zf5H$!nT#M*gS}~Bv69uhMbOX(fW;XK+G#ncLA{UWWM2%tF=zTPC#Pw_bqEzr#=)6s z4ha`QxG<71*{xUDC#vHwEnMPo4>wB{J)ben?6T>oI*A z>~XEcJU=HhRVbLV{RE3qs9;Xno}Z_gj*}wCclICqhxSdR$Lm3+orI%3=FDmT1HdpR z>>qyg%tF-pBg)ivSYf3+%a*u7e92^^YcDa)}PJ(l*9fg888j8AyM|n6rT&M z{U0X*({(&B4tsX{n!}#g8BCY3B2j1l@c9Abm%=EdNb~@)OnCg5{}oiM_MM6;VcN`! zM4j>90o-cO>l>yOD6|x3{Hq|twF2FCO6wp#XYABxp6Ly+t+d$l|6fkj00@QkOzsZP z_$?6N+~xSZuHtj!d_EknKP+s=#s3-5bOk*wXi+Yd0=d{7a`KFH7Uno zA8g0`VlYOGtk=qK}TWM+TSu{iBu#;{K_kk=3A8rrd me-{A8ZMT? +#include "utils.h" + +/* +The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. + +Find the sum of all the primes below two million. + +https://projecteuler.net/problem=10 +*/ +int main(int argc,char**argv) { + FILE*f=fopen("archives/primegenerator/primes","r"); + long sum=0; + int ch=' '; + while ((ch=fgetc(f))!='{'); + while (true) { + int digit=0; + while ((ch=fgetc(f))!=',') { + digit*=10; + digit+=ch-'0'; + } + if (digit>=2000000) { + break; + } else { + sum+=digit; + } + } + fclose(f); + printf("\n\nThe sum of all primes below 2000000 is %ld",sum); + return 0; +} \ No newline at end of file diff --git a/archives/10/src/utils.h b/archives/10/src/utils.h new file mode 100644 index 0000000..d785fa2 --- /dev/null +++ b/archives/10/src/utils.h @@ -0,0 +1,7 @@ +#define true 1 +#define false 0 +#define boolean char +struct String{ + int length; + char*str; +}; \ No newline at end of file diff --git a/current b/current index b7681a5e1f2e54f9f06d32b6e454346c2cd6aa4a..d5b5ef4a840c616c465f120765cc67ca1cb902e1 100755 GIT binary patch delta 2407 zcmZ`*eN0TsCvJL=?*CH0R*mh2A*#&n69C5vMw#(^`&EtvtMNy$hAbP>(;dG7l_M&fPWJ@nGmLrIA;US+<hM6&E4D4 zM|E;jr>MWcghNF?x!`NtcGDFXEZBBtUqL46+*>90c`mS_9R8(at32rGM-X55M^WM@ zae=oi-5~KfJ!tNKih1#rA&JkUTn_tJ|gBbUOdBqX1%(3zSj;9dG_oj#CNPb{JpQLJp9Oa z)E9nSB@gAKBKy_D*?-G@i`IDcWV5|C>7r=uX=9$S)wI<$G`<;Zm+*L;4xS1&2is~o zTG}+&PRQoXM;n4-d*^AfrCzLQY7$kwcCj|t)Y2v9=c-L?Y!@?|PBMRVySW5Qgs_5* z{i-NuklL0MC4y8$%Hj?zDNic_9F#9B$_!H5ilVR-pN9{`y>u0(M8V=k;|h2n?x77p zox+O q`f+72ANi(e}`{gN^LPucoS2a^&_pKslSM~ek<4ZrkdIN~fz@Zwb9%uAV^ zvoCDnBKmO+z*LUJ$L-9X5Qj!c1gI;6j)Bu9(I`~n_!6|bBtD`aF5@5uV8WHb%lZw> zR?OM}%)4H}p!1{*TZMk||5TI~CWD&X6tE@w={WfEQy^wafEmfkd-a>SLZ^YrSt*0! z+{?KFt-!F;%p7SzD$oIj61EUI5su`Q(Gc{aFc~v9fx?)Ic)Vlg^CTJoK3~9P@cC)x zG+dNVMLt9V8HZLx5eVmZ(Iub-fob&RyB3fP^+j}qp4 zq~H*}2KNdihj9ZMIyY1uHlwo;J?QtNA-%5-QgD{aLSZezhV)xFTbM!TV6-rcUWBPa z39Lowo0IUqu$yp|cCZ&cLr;LSNT98(cMPM*#`e)`xX|cjs6^>C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7sl;~5u(`O%@bl6|cu82GA7aa9VUK4kbtK0<$`Y)Mo6~O;flJjQ zpDJaO(NA8G6x^$J(KK*gk@muRuZy054lnYwo1@=j2aI}Md`7!stR(EKfE(VYs0Ey& z%aAj{2C<7y!?@^5ej_?4`kSi}XbyY3ks}uH)C#l$d%JN7$uJ3BwRJQIL#VNmHkd#= zzI%vxjO%u-NZWz06X+QBcB372Aw+5H?M8u2!z+kV5UcB_XMxrW&h)jyC4bJ5E%>MN&5;HpntT#UE4)PNb5!X4jZbUVzU({5DS*ro*aiFx@d3^fSO zlW64)PGWh;dJZNU1a6!;#MwcZX()I0XsA;whI;(a*#z*7LhUD-wN-m&)uV*gNo@t& zLo0mA);DL+x&|f;Wy$fz2C6^z#&xHX=hvO5$;J%_D7^@yO(NfGLTC8t@&wG(ErZ#n zm3&UK=&}Ty%_3*f4wMCUHv72>4OKv**!`a(P#rMV1@nw&jqy{gOCXL zxi$^8Au5OYfUWSOt=A$9&W$3cUx5_t+_;T~VH9-_eoALH`nfT;ngqdv*W%~&4M#pA s{cxlqf#|^x^Gu7su=y#i=rTBi3Uz=p=2000000) { + break; + } else { + sum+=digit; } } + fclose(f); + printf("\n\nThe sum of all primes below 2000000 is %ld",sum); return 0; } \ No newline at end of file