Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OddSum {
- /**
- Example output if user enters 10:
- Max?
- 1 + 3 + 5 + 7 + 9 = 25
- 25 = 9 + 7 + 5 + 3 + 1
- Example output if user enters 11:
- Max?
- 1 + 3 + 5 + 7 + 9 + 11 = 36
- 36 = 11 + 9 + 7 + 5 + 3 + 1
- */
- public static void main(String[] args) {
- int i;
- int max;
- int sum = 0;
- TextIO.putln("Max?");
- max = TextIO.getlnInt();
- for(i = 1; i <= max; i+=2)
- {
- TextIO.put(i);
- sum += i;
- if(i % 2 != 0){
- }
- }
- TextIO.put(i + " ");
- } // end of main method
- } // end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement