#include<stdio.h>
int main()
{
    int x[100];
    int a,b,c=1,o=0,i,z,g,y=0,h=0;
    scanf("%d",&a);
    z=a;
    b=a;
    o=0;
    for(int q=9;q<b;b)
    {
        h=0;
        o=0;
        c=1;
        z=b;
        for( i=10;i<=a;i*=10)
        {
            z=z/i;
        }
        for( y=10;y<=i;y*=10)
        {
            // printf("%d ",y);
            x[o]=b%y;
           // printf("%d ",x[o-1]);
            if(o>0)
                x[o]=x[o]-x[o-1]*(c/10);
           
            x[o]=x[o]/c;
            h+=x[o];
            o++;
            c*=10;
        }
        
        b=h;
        a=b;
        o=0;
       // printf("%d\n",h);
    }
    printf("%d",b);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: