diff --git a/.gitignore b/.gitignore index a1c2a23..4aa7a04 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +launch.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 55aaf70..1704183 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,27 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - runRutabega", + "request": "launch", + "mainClass": "ClassProblems.Class3.runRutabega", + "projectName": "H212_e5d32889" + }, + { + "type": "java", + "name": "CodeLens (Launch) - Rutabega", + "request": "launch", + "mainClass": "ClassProblems.Class3.Rutabega", + "projectName": "H212_e5d32889" + }, + { + "type": "java", + "name": "CodeLens (Launch) - fib0", + "request": "launch", + "mainClass": "ClassProblems.Class3.fib0", + "projectName": "H212_e5d32889" + }, { "type": "java", "name": "CodeLens (Launch) - E1_17", diff --git a/ClassProblems/Class3/Rutabega.java b/ClassProblems/Class3/Rutabega.java new file mode 100644 index 0000000..4a3d2a4 --- /dev/null +++ b/ClassProblems/Class3/Rutabega.java @@ -0,0 +1,18 @@ +package ClassProblems.Class3; + +import java.math.BigInteger;/** + * Rutabega + */ +public class Rutabega { + + public static BigInteger fun(BigInteger index) { + return index.add(new BigInteger("1")); + + } + public static void main(String[] args) { + BigInteger result = Rutabega.fun(new BigInteger("9223372036854775807")); + System.out.println(result); + + // System.out.println(Rutabega.fun("1")); + } +} \ No newline at end of file diff --git a/ClassProblems/Class3/fib0.java b/ClassProblems/Class3/fib0.java new file mode 100644 index 0000000..075df42 --- /dev/null +++ b/ClassProblems/Class3/fib0.java @@ -0,0 +1,24 @@ +package ClassProblems.Class3; + +/** + * fib0 + */ +public class fib0 { + + private static long[] f = new long[92]; + + public static long fib(int n){ + if (n == 0) + return 0; + if (n == 1) + return 1; + if (f[n] > 0) + return f[n]; + + f[n] = fib(n-1) + fib(n-2); + return f[n]; + } + public static void main(String[] args) { + System.out.println(fib(5)); + } +} \ No newline at end of file diff --git a/ClassProblems/Class3/runRutabega.java b/ClassProblems/Class3/runRutabega.java new file mode 100644 index 0000000..c474bd2 --- /dev/null +++ b/ClassProblems/Class3/runRutabega.java @@ -0,0 +1,14 @@ +package ClassProblems.Class3; + +import java.math.BigInteger; + +/** + * runRutabega + */ +public class runRutabega { + + public static void main(String[] args) { + BigInteger result = Rutabega.fun(new BigInteger("21421421")); + System.out.println(result); + } +} \ No newline at end of file diff --git a/ClassProblems/Class3/whatever.java b/ClassProblems/Class3/whatever.java new file mode 100644 index 0000000..7f7959e --- /dev/null +++ b/ClassProblems/Class3/whatever.java @@ -0,0 +1,15 @@ +public class whatever{ + // public static long fun(int index) { + // if (index == 1 ) return 1l; + // else if (index == 2) return 2l; + // else return fun(index-1) + fun(index-2); + + public static long fun(int index, long a, long b) { + if (index == 0 ) return b; + else return fun(index-1, b, a+b); //accumulated passing style + //homework01 using BigIntegers + } + public static void main(String[] args) { + + } +} \ No newline at end of file diff --git a/Homework/Homework01.java b/Homework/Homework01.java new file mode 100644 index 0000000..25bf15a --- /dev/null +++ b/Homework/Homework01.java @@ -0,0 +1,10 @@ +package Homework; +import java.util.Dictionary; + + +public class Homework01 { + Dictionary d = new Dictionary(); + public static int fib(int n) { + + } +} \ No newline at end of file diff --git a/PrincetonJava/Booknotes/Chapter1.txt b/PrincetonJava/Booknotes/Chapter1.txt index 2929048..bb7b763 100644 --- a/PrincetonJava/Booknotes/Chapter1.txt +++ b/PrincetonJava/Booknotes/Chapter1.txt @@ -62,5 +62,10 @@ Characters and Strings Double.parseDouble() Integers - + +Methods - java programs are classes, its functions are Methods + static Methods + public static int fun(int index) + non-static Methods + public int fun(int index)