num = [int(d) for d in input("Enter the Number:")]
sum = 0
for i in range(0, len(num)):
sum = sum + num[i]
print("Sum of Digits of a Number: {}".format(sum))
# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
var value = 2568,
sum = 0;
while (value) {
sum += value % 10;
value = Math.floor(value / 10);
}
console.log(sum);
<?php
$num = 3434654567;
$rem = 0;
$sum = 0;
for($i = 0; $i <= strlen($num); $i++) {
$rem = $num % 10;
$sum = $sum + $rem;
$num = $num/10;
}
echo "Sum of digits is $sum";
?>