Created
October 12, 2011 04:26
-
-
Save ellbur/1280269 to your computer and use it in GitHub Desktop.
Sevens puzzle
This file contains 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 Sevens { | |
public static void main(String[] args) { | |
int min = 1; | |
int max = 100; | |
int seven = 0; | |
for (int k=min; k<=max; k++) { | |
if ((k / 1) % 10 == 7) { | |
seven++; | |
} | |
if ((k / 10) % 10 == 7) { | |
seven++; | |
} | |
if ((k / 100) % 10 == 7) { | |
seven++; | |
} | |
if ((k / 1000) % 10 == 7) { | |
seven++; | |
} | |
if ((k / 10000) % 10 == 7) { | |
seven++; | |
} | |
} | |
System.out.println(seven); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment