Skip to content

Instantly share code, notes, and snippets.

@carlosdlf
Last active April 22, 2016 00:25
Show Gist options
  • Save carlosdlf/ce68a16bf762e03c39b2005f8692cb64 to your computer and use it in GitHub Desktop.
Save carlosdlf/ce68a16bf762e03c39b2005f8692cb64 to your computer and use it in GitHub Desktop.
/**
* Created by clarico on 21/04/2016.
*
* https://projecteuler.net/problem=546
*
*/
public class P546 {
public static void main(String[] args) {
//loops
int l = 1;
// k
int a = 7;
// n
int b = 10;
System.out.println("final "+problem546(l,a,b));
}
public static int problem546(int l, int a, int b) {
if(b == 0){
System.out.println(l*1);
return l*1;
}
int div = b/a;
int mod = b%a+1;
System.out.println(div+" "+mod);
int result = 0;
for (int i = 0; i < div ; i++) {
System.out.println(a + " "+ " "+ a + " "+i);
result = result + problem546(a, a, i);
}
if( mod > 0){
System.out.println("* "+mod + " "+ a + " "+div);
result = result + mod*problem546(l, a, div);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment