Digital root by Lukass

#include <iostream>\x0d
#include <ios>\x0d
using namespace std;\x0d
main(){long n,m,s;while(1){cin>>m;n=m;if(cin.eof())break;while(n>9){while(n>0){s+=n%10;n/=10;}n=s;s=0;}cout<<"digital_root("<<m<<")="<<n;while(m<100000000){m*=10;cout<<" ";}cout<<endl;}}\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page