Commits

committed db887b0

• Participants
• Parent commits 0721213
• Branches default

File problem0005/5.py

• Ignore whitespace
`+# Since the smallest number for being divisible is 2520 `
`+# is stands to reason 1-20 must be larger`
`+x = 2510`
`+IsDivisibleFrom1To20 = False`
`+while not IsDivisibleFrom1To20:`
`+    # In order by be evenly divible by 10 it must be a factor of 10`
`+    x = x + 10`
`+`
`+    # Go through the numbers. `
`+    # Everything is divible by 1, and we know it is even so 2 works too`
`+    for y in range(3,20):`
`+        if x % y != 0:`
`+            break`
`+    else:`
`+        IsDivisibleFrom1To20 = True`
`+print x`

File problem0006/6.c

• Ignore whitespace
`+#include<stdio.h>`
`+#define TRUE 1`
`+#define FALSE 0`
`+long AddSquares(int limit);`
`+long SquareSum(int limit);`
`+int main()`
`+{`
`+    int limit = 100;`
`+    long sumOfSquares;`
`+    long squareOfSum;`
`+    sumOfSquares = AddSquares(limit);`
`+    squareOfSum = SquareSum(limit);`
`+    printf("Sum Of Squares: %ld\n", sumOfSquares);`
`+    printf("Square Of Sum: %ld\n", squareOfSum);`
`+    printf("Difference: %ld\n", squareOfSum-sumOfSquares);`
`+`
`+    return 0;`
`+}`
`+`
`+long AddSquares(int limit)`
`+{`
`+    int x;`
`+    long sum = 0;`
`+    for (x=1;x<=limit;x++)`
`+        sum += (x*x);`
`+`
`+    return sum;`
`+}`
`+`
`+long SquareSum(int limit)`
`+{`
`+`
`+    int x;`
`+    long sum = 0;`
`+    for (x=1;x<=limit;x++)`
`+        sum += x;`
`+`
`+    return sum*sum;`
`+}`

File problem0009/9.c

• Ignore whitespace
`+#include<stdio.h>`
`+#include<math.h>`
`+`
`+int main()`
`+{`
`+    int a,b;`
`+    int c1,c2;`
`+`
`+    for (a=1;a<1000;a++)`
`+    {`
`+        for (b=1;b<1000;b++)`
`+        {`
`+            c1 = sqrt((a*a) + (b*b));`
`+            c2 = 1000 - (a + b);`
`+            if (c1 == c2 && (c1*c1) == a*a + b*b)`
`+                goto end;`
`+        }`
`+    }`
`+end:`
`+    printf("a = %d;b = %d;c = %d\n", a, b, c1);`
`+    printf("abc = %d\n\n", a*b*c1);`
`+    return 0;`
`+}`