Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 11 files changed
  • 0 commit comments
  • 2 contributors
View
BIN astera/5/euler5
Binary file not shown.
View
24 astera/5/euler5.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdbool.h>
+
+bool modzero(int num)
+{
+ int j = 1;
+ for (j = 1; j <= 20; j++) {
+ if (num % j) {
+ return false;
+ }
+ }
+ return true;
+}
+
+int main() {
+ int i = 1;
+ while (true) {
+ if (modzero(i)) {
+ printf ("The number is %d\n", i);
+ break;
+ }
+ i++;
+ }
+}
View
BIN astera/6/euler6
Binary file not shown.
View
21 astera/6/euler6.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int funct1(int count) {
+ int i = 1;
+ int sum1 = 0;
+ for (i = 1; i <= count; i++) {
+ sum1 += i*i;
+ }
+ return sum1;
+}
+
+int funct2(int count) {
+ int sum2 = count / 2 * (1 + count);
+ return sum2*sum2;
+}
+
+void main() {
+ int count = 100;
+ int diff = funct2(count) - funct1(count);
+ printf ("%d\n", diff);
+}
View
12 astera/6/euler6.py
@@ -0,0 +1,12 @@
+def funct1():
+ sum1 = 0
+ for i in xrange(1,101):
+ sum1 += i**2
+ return sum1
+
+def funct2():
+ sum2 = sum (xrange(1,101))
+ return sum2**2
+
+diff = abs(funct1() - funct2())
+print diff
View
15 astera/6/euler6.rb
@@ -0,0 +1,15 @@
+def funct1
+ sum1 = 0
+ for i in (1..100)
+ sum1 += i**2
+ end
+ return sum1
+end
+
+def funct2
+ sum2 = (1..100).inject {|sum, i| sum + i}
+ return sum2**2
+end
+
+diff = (funct1 - funct2).abs
+puts diff
View
9 astera/7/euler7.rb
@@ -0,0 +1,9 @@
+require 'mathn'
+
+a = Array.new
+
+Prime.each(120000) do |prime|
+ a << prime
+end
+
+puts "The 10,001st prime number is #{a[10000]}."
View
BIN astera/9/euler9
Binary file not shown.
View
18 astera/9/euler9.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+int main() {
+ int a, b, c;
+ int num = 1000;
+ int result;
+
+ for(a = 1; a < num; a++) {
+ for(b = a; b < num; b++) {
+ if((a*a + b*b) == ((num - a - b)*(num - a - b))) {
+ c = (num - a - b);
+ result = a*b*c;
+ printf("%d\n", result);
+ break;
+ }
+ }
+ }
+}
View
9 astera/9/euler9.py
@@ -0,0 +1,9 @@
+num = 1000
+
+for a in xrange(1, num):
+ b = ((num*a - ((num**2)/2))/(a - num))
+ c = num - a - b
+
+ if ((a**2 + b**2) == c**2) and a < b:
+ result = a * b * c
+ print result
View
10 astera/9/euler9.rb
@@ -0,0 +1,10 @@
+num = 1000
+
+for a in (1..num)
+ for b in (a..num)
+ if a*a + b*b == (num - a - b)*(num - a - b)
+ c = num - a - b
+ puts "a = #{a}, b = #{b}, c = #{c} -- result = #{a*b*c}"
+ end
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.