-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEuler_Problem-006.b93
27 lines (22 loc) · 1.23 KB
/
Euler_Problem-006.b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"d"10p000p>10g:00g+00p1-:#v_$010p>"c"10g::1+:*\:5:+%\5:+/6+p`#v_ v
>$.@ ^ p01< ^ p01+1g01 < 0
> v
|!:\<|p01-1:g01<$$_v#!:g+6/+:5\%+:5:g01 :< p01"c"+<_v#!p01:-1g01<p01:g0<
\ ^< >` > #v_v
> v v-g+6/+:5\%+:5:g01< >00g ^
##########> ^
########## >010g:5:+%\5:+/6+pv
##########
########## ^ < <
##########
##########
##########
##########
##########
##########
---------------------------------------
My solution here is *far* more complex than necessary, mostly because I thought the temporary numbers would get too big for int32 to handle (especially sum(1,100)^2).
Later I found out I could just calculate the sum of the squares and the square of the sum and subtract them ...
But I like my solution so I'll leave it here.
While I calculate the the second value (using the distributive property), I subtract in every step as much parts of the first value (the single elements of the addition) as I can (without going negative).
That way my temporary values never greatly exceed the final result.