Kavya-24 / Snippets

Hacktoberfest 2024
41 stars 270 forks source link

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

Open Prathamesh-1011 opened 1 week ago

Prathamesh-1011 commented 1 week ago

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

Prathamesh-1011 commented 1 week ago

@Kavya-24 Please assign me this under the Octoberfest 2024 Label :) and a good first issue