Skip to content

Commit

Permalink
class 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydattolo committed Jan 21, 2020
1 parent 0ab5290 commit f0dddc2
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

launch.json
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions ClassProblems/Class3/Rutabega.java
Original file line number Diff line number Diff line change
@@ -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"));
}
}
24 changes: 24 additions & 0 deletions ClassProblems/Class3/fib0.java
Original file line number Diff line number Diff line change
@@ -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));
}
}
14 changes: 14 additions & 0 deletions ClassProblems/Class3/runRutabega.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
15 changes: 15 additions & 0 deletions ClassProblems/Class3/whatever.java
Original file line number Diff line number Diff line change
@@ -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) {

}
}
10 changes: 10 additions & 0 deletions Homework/Homework01.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package Homework;
import java.util.Dictionary;


public class Homework01 {
Dictionary d = new Dictionary();
public static int fib(int n) {

}
}
7 changes: 6 additions & 1 deletion PrincetonJava/Booknotes/Chapter1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f0dddc2

Please sign in to comment.