////////////////////////////////////////////
//1068(其他进制是否回文数)
#include<iostream>
using namespace std;
unsigned int st[100];
//判断数组st是否前len位是否为回文数
bool deter_palin(int len)
{
int i;
bool flags=1;
for(i=0;i<len/2;i++)
{
if(st[i]!=st[len-1-i])
{
flags=0;
break;
}
}
return flags;
}
//对每一基数basenum进行进制转换,通过调用deter_palin(),判断该进制数是否为回文数
bool base_chang(unsigned int n,int basenum)
{
int k=0;
while(n!=0)
{
st[k++]=n%basenum;
n/=basenum;
}
if(deter_palin(k))
return 1;
else
return 0;
}
int main()
{
unsigned int n;
while(cin>>n && n!=0)
{
int i;
bool flags=0;
for(i=2;i<=16;i++)
{
if(base_chang(n,i))
//只需第一个前输出字符句子
if(flags==0)
{
cout<<"Number "<<n<<" is palindrom in basis "<<i;
flags=1;
}
else
cout<<" "<<i;
}
if(flags==0)
cout<<"Number "<<n<<" is not a palindrom";
cout<<endl;
}
return 0;
}