From bbab1294fc2bb93c53ddbd8d312d60d637590633 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Thu, 14 Jul 2022 18:00:41 +0000 Subject: [PATCH] Completed Co-authored-by: sigonasr2 --- archives/5/current | Bin 0 -> 16696 bytes archives/5/src/main.c | 29 +++++++++++++++++ archives/5/src/utils.h | 7 +++++ current | Bin 16856 -> 16696 bytes src/main.c | 69 ++++++++++------------------------------- 5 files changed, 52 insertions(+), 53 deletions(-) create mode 100755 archives/5/current create mode 100644 archives/5/src/main.c create mode 100644 archives/5/src/utils.h diff --git a/archives/5/current b/archives/5/current new file mode 100755 index 0000000000000000000000000000000000000000..fe9e79feb571216316416c2f4353e569ed9617b4 GIT binary patch literal 16696 zcmeHOZ*Wvs6~CL!pXJ{sP>=-_9!f{BlSe`!hIS&mNjALggg-)J=@k01$!?O>WH;`< zrAbE+C$!@ZjWT}l|BUUYcErw9KREP*8pHyQV+TIyptU1b(Nx+RkQP*6J?Fl2Ht*eR zaE9@NGrpU7@7()4=XdUX=iT@A-n@H1AMNa@@c9HMzxaf}QcsQR71H^VzxeP3((r>Vuf1<2={|TUI;T~#n|{u@9^hZ7?C9y9AcGKcJ0$ z{a--1)V(hxUmKRd9H(u7Yh`o`09#T9Upoi>IN(|t`%lk-qwf!wu@?~6J`7`%7|Ev6 zR=+UKzR|eZpGwDvQcoqJh!$qfif1izIG#$2?VYjKHgl7{N#7#OSl13Sk<2CsQaLM` z?b^{clu0MM;=M!292m}|iD}xVWeu@e6%=KTwNK#R%WX^j7A zdUsdnMAZ*r=xaseF`&rq0J0oOT|fYX_(H=yi009+UUttUZ=j=F&d!PE+e-Zl#P zOJ}1uafp8=dc$`%dJD5xmLH4W{Kkz#w+iRsYN|mauFM|?-T0wfOAr6?$e|m;3V})C z3|v<-2>(6+l9+noPO*5UdK}zc`GG`!4ox_UDjDy{qn#5iR~`@|@~K$i*OBg6;k`&# zq;RX-n5h39z9zv0WShx1iT1%5%415MZk-I z7XdE<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3%`+@dRLa ziOlEu&q*4%8Ax&@=CiB@vXd{uWZYm&u7_PPkIM^zj2PF?Th9I}%>} literal 0 HcmV?d00001 diff --git a/archives/5/src/main.c b/archives/5/src/main.c new file mode 100644 index 0000000..ed603b2 --- /dev/null +++ b/archives/5/src/main.c @@ -0,0 +1,29 @@ +#include +#include "utils.h" + +/* +2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. + +What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? + +https://projecteuler.net/problem=5 +*/ +int main(int argc,char**argv) { + int numb=1; + while (true) { + boolean isDivisible=true; + for (int i=1;i<=20;i++) { + if (numb%i!=0) { + isDivisible=false; + break; + } + } + if (isDivisible) { + printf("%d is divisible!",numb); + break; + } else { + numb++; + } + } + return 0; +} \ No newline at end of file diff --git a/archives/5/src/utils.h b/archives/5/src/utils.h new file mode 100644 index 0000000..d785fa2 --- /dev/null +++ b/archives/5/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 f04183aee6771206191ee04dd07b10616c639644..fe9e79feb571216316416c2f4353e569ed9617b4 100755 GIT binary patch delta 1983 zcmZ8ie{2&~9DncHE4^*dyROZ(fV3TwZIJc0bzQfyt}Rl%8H^wfF`DcLgII$Mwt`#Y zWOHb2a0%m^C~7qFj}Fkp+Qf7*n5q$GOcegm45JY+nkE~O;dGmsoZsu+4Z=0|KJWYE zec$JO-}if+8ll;j=n0p-gC~V2ssZV59NYLlM=ZKHc10?RGnx=*z)t<{XQ(C`Nc0F4 z#;Awetvh$XFcpQ#D$RE?tRtME-`ibYO}c}ynpp?qOw^av7i9GX2FiL^88}nBqkK=y zyxI2k=!$dS{xd)S`q}$uC%o{2slut!R_STRBM>u-z?)sv2iHs@eM*(- zvpBAyWsqhZ{QgAO9)Dktzn&cIO&mz>gRHp>el_o0K?s9C0%3MN7tolKEDW=vkkeUO zbuEE0b`zy=o)z6DLx-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NxEx!egiyw6YuB|f*)Z`Tn&Rn;EOL90IpoM|!yOLJk`VuPeF-4S%^P7RZDJ~zb? z7yTmjW3qWx2ae$>5osrvY?-7e4Zc~ji?+Zp8nZ|*oI~RoF4+XqnG1g_@zO8|r6Oi8 zl;&CUa4sQD3ZW#DDL9JKI4GsZuxGSP6o~O1(o-PB14qk52$o5R&{`(C%u1Q|7m%TZ zsoCMBm0S=f7#G$YajJCTx>iWXHfSy|DCAE7U!gqEy!sXl*t3zv#G>yBEjI3 zyXzl+qPf&t>a8G01|kRB`x<-pMe*8l7~ZmNg5#CLCHn2<%dXAM2mAY*`=hOWQM}!B z9U)!)4^Ey*SJi1cIaS?4={0cG_=GdYCD5d!Fjtxb-8CBpbKRRX8^&sU4ra8I!CXzH zqtlQ&L8z@<-9_eZVsM~#Xtf0}Tr0vSwE`RuI3Yja&+j$%j7j}QT{OpI0b%tHYj)v+ z6@C=(W|#{D_sW&PF5D}w9d4+qa|&TeM=)t49H{dN6Nc8L4KP;cbC@f79OmjO9p>uC t9k;U*X6u{~-sxXm*W*U}!!Wi}rO(4yu+lNLT_0-~Tn|>#&p`-n{x4(`C*=SD diff --git a/src/main.c b/src/main.c index 0e22600..ed603b2 100644 --- a/src/main.c +++ b/src/main.c @@ -2,65 +2,28 @@ #include "utils.h" /* -A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. +2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. -Find the largest palindrome made from the product of two 3-digit numbers. +What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? -https://projecteuler.net/problem=4 +https://projecteuler.net/problem=5 */ - -struct String numberToString(int numb) { - int placeValues=0; - int tempNumb=numb; - while (tempNumb>0) { - tempNumb/=10; - placeValues++; - } - char*finalStr=malloc(placeValues+1); - tempNumb=numb; - int marker=placeValues-1; - while (tempNumb>0) { - finalStr[marker--]='0'+(tempNumb%10); - tempNumb/=10; - } - struct String str={placeValues,finalStr}; - return str; -} - -boolean isPalindrome(struct String numb) { - int offset=0; - while (offset0;numb1--) { - for (numb2=999;numb2>0;numb2--) { - struct String str = numberToString(numb1*numb2); - if (isPalindrome(str)) { - printf("%d is a Palindrome!\n",numb1*numb2); - if (maxPal