So I'm writing a Java program that calculates the difference between the sum of the squares of the first 100 integers and the square of the sum of the first 100 integers:
class project_euler6 { public static int sum_of_squares(int start, int end) { int total = 0; while (start <= end) { total += (start * start); start++; } return total; } public static int square_of_sums(int start, int end) { int total = 0; while (start <= end) { total += start; start++; } total *= total; return total; } public static void main(String[] args) { int first_total = sum_of_squares(1, 100); int second_total = square_of_sums(1, 100); int difference = Math.abs(first_total - second_total); System.out.println("The difference between the sum of the squares and the square of the sums of first 100 integers is " + difference); } } When I run it, I get this strange error:
Exception in thread "main" java.lang.NoClassDefFoundError: project_euler6/java Caused by: java.lang.ClassNotFoundException: project_euler6.java at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Not sure where to start on this one...
Any help much appreciated, Mariogs
java project_euler6.javarather thanjava project_euler6.