Mathematic calculation

Status
Not open for further replies.

Nitai Chand

Member
I have a date. Example: 08/06/1985 . I want to perform a mathematical operation. Where all the digits will be added to reduce it to single digit.
In this case 08/06/1985 ->0+8+0+6+1+9+8+5=37
Then 37 -> 3+7 =10
Then 10 -> 1+0 =1
Thus 08/06/1985 reduced to 1.
This I required for numerology calculation.
Please guide how will I be able to do it.
 
P

Pabblymember11

Guest
Hey @Nitai Chand

Regarding your concern, you can use the Code action step with Python language where you can perform the same calculation accordingly.

Please refer to the following screenshot for a better understanding.

1690181825634.png


def reduce_to_single_digit(date_str): # Remove any non-numeric characters from the date string digits_only = ''.join(filter(str.isdigit, date_str)) # Convert the string to a list of digits digits_list = list(map(int, digits_only)) # Calculate the sum of all digits total_sum = sum(digits_list) # Reduce the sum to a single digit while total_sum > 9: total_sum = sum(int(digit) for digit in str(total_sum)) return total_sum # Test the function with the example date "08/06/1985" input_date = "08/06/1985" result = reduce_to_single_digit(input_date) print(result) # Output: 1
 
Status
Not open for further replies.
Top