Created
April 10, 2018 19:16
-
-
Save lbattaglioli2000/2cdedd79664895037fb59c17e0d00943 to your computer and use it in GitHub Desktop.
doesn't work :/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyProgram | |
{ | |
public static void main(String[] args) | |
{ | |
scubey(); | |
} | |
public static void scubey() | |
{ | |
for(int i = 0; i <= 99; i++) | |
{ | |
int sum = i; | |
int max = 0; | |
int min = 0; | |
int subtractor = 0; | |
for(int j = 2; j < 100; j++) | |
{ | |
if(Math.pow(j, 3) > i) | |
{ | |
j = j - 1; | |
max = j; | |
subtractor = j; | |
break; | |
} | |
} | |
while(true) | |
{ | |
sum -= Math.pow(subtractor, 3); | |
if(sum == 0) | |
{ | |
min = subtractor; | |
break; | |
} | |
if(sum < 0) | |
{ | |
break; | |
} | |
subtractor--; | |
} | |
System.out.println("i: " + i + "\nmin: " + min + "\nmax: " + max); | |
} | |
} | |
public static int grid(int n, int m) | |
{ | |
/** | |
* In general for an M by N grid, the total number of squares is | |
* (M)(N) + (M - 1) (N – 1) + (M – 2)(N – 2) + … + (1)(N – M + 1) | |
*/ | |
int sum = 0; | |
for(int i = 0; i <= n; i++) | |
{ | |
sum += (m - (i+1)) * (n - (i+1)); | |
} | |
return (m * n) + sum + (1 * (n - m + 1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment