tag:blogger.com,1999:blog-2012573949883447809.post3996788473619949023..comments2024-02-06T11:01:09.832+01:00Comments on void-main-args: Problem: Euler task 1voidmainargshttp://www.blogger.com/profile/00911109433888554531noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2012573949883447809.post-7583686430230481002023-08-18T07:37:59.472+02:002023-08-18T07:37:59.472+02:00Thankss great blogThankss great blogRevista Preseihttps://revista-presei-m.blogspot.com/noreply@blogger.comtag:blogger.com,1999:blog-2012573949883447809.post-76762522203264065712010-10-30T16:36:11.372+02:002010-10-30T16:36:11.372+02:00sure.
it's also challenging to compute it an...sure. <br /><br />it's also challenging to compute it analytically, but my challenge was to count it programmatically.<br /><br />btw, it's not really a loop :-)voidmainargshttps://www.blogger.com/profile/00911109433888554531noreply@blogger.comtag:blogger.com,1999:blog-2012573949883447809.post-44319466852944428062010-10-30T15:51:37.283+02:002010-10-30T15:51:37.283+02:00Wouldn't it be faster to actually calculate th...Wouldn't it be faster to actually calculate them?<br />knowing that between 1 and 10 the multiples of 3 are<br />3,6,9 or <br />3*1 + 3*2 + 3*3 <br />= 3*(1+2+3)<br />or 3* (1+k) * k/2<br />We can calculate based on any n:<br />k1 = n/3 <br />k2 = n/5<br />k3 = n/15 (multiples of 15 which are both divisible by 3 and 5 are counted twice, so we need to substract it) <br />therefore x = 3*(1+k1)*k1/2 + 5*(1+k2)*k2/2 - 15*(1+k3)*k3/2<br /><br />It's cheating :) if you really want to work with loops but hey....Rezahttp://www.cse.msu.edu/~ferrydianoreply@blogger.com