4 solutions

  • 0
    @ 2025-10-23 23:10:34
    #include <bits/stdc++.h>
    using namespace std;
    int number(int n)
    {
        int t=0;
        int s = 0;
        while(n!=0)
        {
            t = n;
            t = t%10;
            s+=t;
            n/=10;
        }
        if(s<10)
        {
            return s;
        }
        else
        {
            return number(s);
        }
    }
    int main()
    {
        int n;
        cin>>n;
        cout<<number(n);
    }
    

    Information

    ID
    110
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    28
    Accepted
    12
    Uploaded By