The program must accept an integer N as the input. The task is to compute and print the quotient obtained after dividing N by the sum of its digits.
Boundary Condition(s):
10 <= N <= 10^9
Input Format:
The first line contains the integer N.
Output Format:
A single line contains the quotient value.
Example Input/Output 1:
Input:
48
Output:
6
Explanation:
The sum of digits in 48 is 12 (4+8). 48 divided by 12 gives the quotient 6. Hence the output is 6.
N = int(input().strip())
sum_of_digits = sum(map(int, str(N)))
print(N // sum_of_digits)
#include<stdio.h>
int main() {
int N, temp, sum = 0;
scanf("%d", &N);
temp = N;
while(temp) {
sum += temp % 10;
temp /= 10;
}
printf("%d", N / sum);
return 0;
}
#include <iostream>
using namespace std;
int main() {
int N, temp, sum = 0;
cin >> N;
temp = N;
while(temp) {
sum += temp % 10;
temp /= 10;
}
cout << N / sum;
return 0;
}
import java.util.Scanner;
public class DivideBySum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int temp = N, sum = 0;
while(temp > 0) {
sum += temp % 10;
temp /= 10;
}
System.out.println(N / sum);
}
}