#include <iostream>
#include <math.h> // for std::pow()
unsigned int get_length(unsigned int num,const unsigned int base=10)
{
unsigned int len=1;
while(num && (num/=base))
++len;
return( len );
}
bool is_armstrong(const unsigned int num,const unsigned int base=10)
{
unsigned int len=get_length(num,base);
unsigned int sum=0;
unsigned int tmp=num;
while(tmp)
{
sum+=(unsigned int)std::pow((double)(tmp%base),(double)len);
tmp/=base;
}
return(num==sum);
}
int main()
{
std::cout << "Armstrong series (base 10):";
for(unsigned int num=0; num<=0xffffffff; ++num)
if(is_armstrong(num))
std::cout << " " << num;
std::cout << std::endl;
return(0);
}
i dn't know. haha
#include #include void main() { clrscr() int a=0,b=1,c,i,n; coutn cout
#include <stdio.h> int main (void) { puts ("a a b a b c"); return 0; }
C. W. Armstrong was born in 1899.
C. W. Armstrong died in 1986.
Not by itself. If you said a+++b, then that would mean to add the incremented value of b to a and generate a result, but +++b is not valid.
Yes, this can be done. For example for Fibonacci series. You will find plenty of examples if you google for the types of series you need to be generated.
Find the Sum to n terms of the series 5 5+55+555+ +n Terms
C. Michael Armstrong was born on October 18th, 1938.
Samuel C. Armstrong has written: 'Ideas on education'
Samuel C. Armstrong died on 1893-05-11.
Samuel C. Armstrong was born on 1839-01-30.