From 8d15de9cdc25c39483ea067405797d85b67fc261 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Sat, 15 Feb 2025 17:52:41 +0530 Subject: [PATCH] Create 2698. Find the Punishment Number of an Integer --- .... Find the Punishment Number of an Integer | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2698. Find the Punishment Number of an Integer diff --git a/2698. Find the Punishment Number of an Integer b/2698. Find the Punishment Number of an Integer new file mode 100644 index 0000000..eebca1e --- /dev/null +++ b/2698. Find the Punishment Number of an Integer @@ -0,0 +1,28 @@ +class Solution { +public: + int solve(int sum, int n){ + int s = 0; + int x = n; + int m = 1; + while(n){ + s=(n%10)*m + s; + n/=10; + m*=10; + if(s+solve(sum-s,n)==sum){ + // cout<