Skip to content

Add Java Solution for Summing Odd and Even Placed Digits Problem #463

@Prathamesh-1011

Description

@Prathamesh-1011

Description:
This issue is for adding a Java solution to compute the sum of odd-placed and even-placed digits of a given integer N. The solution will print the sum of the digits placed at odd positions followed by the sum of the digits at even positions.

Problem Description:
Input: A single integer N where 0 < N ≤ 1,000,000,000.
Output: The sum of digits placed at odd positions on the first line and the sum of digits placed at even positions on the second line.

Constraints:
The input integer N should be a positive integer not exceeding 1 billion.
Positions are considered 1-based (i.e., the first digit is at position 1, the second digit is at position 2, and so on).

Output Format

Sample Input
2635
Sample Output
11
5
Explanation
5 is present at 1st position, 3 is present at 2nd position, 6 is present at 3rd position and 2 is present at 4th position.

Sum of odd placed digits on first line. 5 and 6 are placed at odd position. Hence odd place sum is 5+6=11

Sum of even placed digits on second line. 3 and 2 are placed at even position. Hence even place sum is 3+2=5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions