Index-1              Index-2              Home Page

Find 1st three (3) Armstrong Number



Write a program to find 1st three (3) Armstrong Number starting from 1

Hints:

The condition for Armstrong number is,
Sum of the cubes of its digits must equal to the number itself.

For example, 407 is given as input.
4 * 4 * 4 + 0 * 0 * 0 + 7 * 7 * 7 = 407 is an Armstrong number.

17 comments:

  1. #include
    using namespace std;

    int main()
    {
    int i,sum=0,rem,temp;
    cout<<"First three armstrong numbre is:"<<endl;
    for(i=1;i<=370;i++)
    {

    temp=i;
    while(temp!=0)
    {
    rem=(temp%10);
    sum+=rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }

    ReplyDelete
  2. #include
    using namespace std;

    int main()
    {
    int i,sum=0,rem,temp;
    cout<<"First three armstrong numbre is:"<<endl;
    for(i=1;i<=370;i++)
    {

    temp=i;
    while(temp!=0)
    {
    rem=(temp%10);
    sum+=rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }

    ReplyDelete
  3. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  4. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  5. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  6. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  7. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  8. /*Amena Akter Anni
    ID:30934
    Betch:47th*/

    #include
    using namespace std;
    void armstrong(int n)
    {
    int j,temp,res=0,sum=0;
    temp=n;
    while(temp>0){
    j=temp%10;
    res=j*j*j;
    temp/=10;
    sum+=res;
    }
    if(sum==n)
    cout<<"The armstrong number is:"<>i;
    armstrong(i);
    }

    ReplyDelete
  9. //Batch:46th , id:201420262
    #include
    using namespace std;
    int armstrong(int sum=0)
    {
    int i, rem, temp;

    for(i=1;i<=370;i++)
    {

    temp=i;
    while(temp!=0)
    {
    rem=(temp%10);
    sum+=rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }



    }
    int main()
    {

    cout<<"first three armstrong number is:"<<endl;
    armstrong( );
    return 0;
    }

    ReplyDelete
  10. mehrin
    id-201430310
    #include
    using namespace std;
    int armstrong_number(int num)

    {


    int i,sum=0,rem,temp;
    cout<<"Armstrong number are: "<<endl;
    for(i=1;i<=1370;i++)
    {
    temp=i;
    while(temp!=0)
    {
    rem =(temp%10);
    sum+= rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }
    int main()
    {
    int num;
    armstrong_number(num);
    return 0;

    }

    ReplyDelete
  11. #include
    using namespace std;
    int armstrong_check(int a)

    {


    int i,sum=0,r,temp;
    cout<<"Armstrong number are: "<<endl;
    for(i=1;i<=5000;i++)
    {
    temp=i;
    while(temp!=0)
    {
    r=(temp%10);
    sum+= r*r*r;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }
    int main()
    {
    int a;
    armstrong_check(a);
    return 0;

    }

    ReplyDelete
  12. sohagi akter sumi
    201420134 betch 46th
    #include
    using namespace std;
    int armstrong_num(int r)

    {


    int i,sum=0,m,n;
    cout<<"Armstrong number are: "<<endl;
    for(i=1;i<=2000;i++)
    {
    n=i;
    while(n!=0)
    {
    m=(n%10);
    sum+= m*m*m;
    n/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }
    int main()
    {
    int r;
    armstrong_num(r);
    return 0;

    }

    ReplyDelete
  13. /*
    Bashir Fardoush
    ID: 201430385
    Betsh; 47th

    Write a program to find 1st three (3) Armstrong Number starting from 1
    */

    #include
    using namespace std;
    int armstrong(int startv)
    {

    cout<<"First 3 Armstrong numbers are: ";
    int i,num=0,temp=0,sum=0,count=0;
    for(i=startv; ;i++)
    {

    num=i;
    while(num!=0)
    {
    temp=num%10;
    sum+=temp*temp*temp;
    num=num/10;

    }

    if(sum==i)
    {

    cout<=3)break;

    }
    cout<<endl;
    }

    int main(){
    int inv;
    inv=1;
    armstrong(inv);
    return 0;

    }

    ReplyDelete
  14. //Batch:46th , id:201420262
    #include
    using namespace std;
    int armstrong(int sum=0)
    {
    int i, rem, temp;

    for(i=1;i<=370;i++)
    {

    temp=i;
    while(temp!=0)
    {
    rem=(temp%10);
    sum+=rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }



    }
    int main()
    {

    cout<<"first three armstrong number is:"<<endl;
    armstrong( );
    return 0;
    }

    ReplyDelete
  15. RIPON
    ID:734
    Betch:47
    //Write a program to find 1st three (3) Armstrong Number starting from 1
    #include
    using namespace std;
    int armstrong_number(int n)

    {
    int i,t,m,h,sum=0;
    cout<<"Armstrong number"<>n;
    for(i=1;i<=h;i++)
    {
    t=i;
    while(t!=0)
    {
    m=t%10;
    t/=10;
    sum+=m*m*m;

    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }
    int main()
    {
    int n;
    armstrong_number(n);
    return 0;

    }

    ReplyDelete
  16. ID-201210433
    Batch 39th
    #include
    using namespace std;

    int main()
    {
    int i,sum=0,rem,temp;
    cout<<"All Armstrong number is:"<<endl;
    for(i=0;i<=1000;i++)
    {
    temp=i;
    while(temp!=0)
    {
    rem=(temp%10);
    sum+=rem*rem*rem;
    temp/=10;
    }
    if(i==sum)
    {
    cout<<i<<endl;
    }
    sum=0;
    }
    return 0;
    }

    ReplyDelete
  17. #include
    using namespace std;
    int armstrong(int inp);
    int main()
    {
    int inp,last;
    cout<<"Enter the range: ";
    cin>>inp;
    last=armstrong(inp);
    cout<<"The last armstrong number is :"<<last;
    return 0;
    }
    int armstrong(int inp)
    {
    int num,r,sum,temp,last;
    for(num=1;num<=inp;num++)
    {
    temp=num;
    sum = 0;
    while(temp!=0)
    {
    r=temp%10;
    temp=temp/10;
    sum=sum+(r*r*r);
    }
    if(sum==num)
    {
    cout<<num<<" ";
    last=num;
    }
    }
    return last;
    }

    ReplyDelete