Snoopchicken
Forum Addict
- Joined
- Jun 13, 2012
- Sythe Gold
- 0
- Messages
- 383
Too tedious. I'll make a program to count to a million for me!
Try it (this is Java). I got 9 seconds (using a netbook though). Here's the last bit (not going to post all of the numbers up to a million):
Code:
public class CountToAMillion {
public static void main(String[] args) {
// Variables
long totaltime, initialtime, endtime;
// Initial checkpoint for processing time
initialtime = System.nanoTime();
// Loop to count to a million
for (int i = 1; i <= 1000000; i++) {
System.out.print(i + " ");
if (i > 10 && i%10 == 0) {
System.out.println(""); // Skips a line for every 10 iterations
}
}
// Calculating and displaying processing time
endtime = System.nanoTime();
totaltime = (endtime - initialtime)/1000000000;
System.out.print("Total time to count to a million: " + totaltime + " seconds.");
} // End main method
} // End class
Try it (this is Java). I got 9 seconds (using a netbook though). Here's the last bit (not going to post all of the numbers up to a million):
Code:
999951 999952 999953 999954 999955 999956 999957 999958 999959 999960
999961 999962 999963 999964 999965 999966 999967 999968 999969 999970
999971 999972 999973 999974 999975 999976 999977 999978 999979 999980
999981 999982 999983 999984 999985 999986 999987 999988 999989 999990
999991 999992 999993 999994 999995 999996 999997 999998 999999 1000000
Total time to count to a million: 9 seconds.




















































