Armstrong Number | To check if a given number is an Armstrong number or not | Java

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 82

  • @Btechquastions-zh5cy
    @Btechquastions-zh5cy 6 місяців тому +5

    class Ambstrong {
    public static void main(String[] args) {
    int n =153;
    int temp;
    int amb = 0;
    int original = n;
    while(n>0){
    temp = n%10;
    temp = (int)Math.pow(temp,3);
    amb = amb+temp;
    n = n/10;
    }
    if(original==amb){
    System.out.println("amb");
    }else{
    System.out.println("not amb");
    }
    }
    }
    Thank you so munch... 👌

  • @prakharsrivastava5130
    @prakharsrivastava5130 2 роки тому +11

    *Check Armstrong number for n digits*
    import java.lang.*;
    import java.util.Scanner;
    public class armstrongNum {
    public static void main(String[] args) {
    // Asking for INPUT from USER
    System.out.print("Enter a Number: ");
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int s = n;
    int m = n;
    double r,q = 1;
    int counter=0;
    double sum=0;

    // To count number of Digits entered by USER
    while (n > 0) {
    r = n % 10;
    n = n / 10;
    counter++;
    }

    // Logic here
    while (m > 0) {
    q = m % 10;
    q=Math.pow(q,counter);
    sum+=q;
    m = m / 10;
    }

    // Checking
    if (sum==s) {
    System.out.println("Yes it is a Armstrong Number");
    } else {
    System.out.println("Not a Armstrong Number");
    }
    }
    }

  • @sarahfatima9840
    @sarahfatima9840 3 роки тому +8

    Splendid!! Your method of first explaining each step before writing the program is amazing. I have been struggling since months to find a good computer teacher and I never understood these concepts but after watching your video I feel blessed. I have understood. Thank you❤️!

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому +2

      Hey thanks... ur satisfaction means a lot to me😊

    • @sarahfatima9840
      @sarahfatima9840 3 роки тому

      @@BTechComputerScience No worries🤭💗

    • @Mulllana_Haramudil-AlHarami
      @Mulllana_Haramudil-AlHarami 2 роки тому

      CS sir with least technology you are best . Your explanation at each & step is amazing 😍. Keep it up ;

  • @keerthanaselvaraj6791
    @keerthanaselvaraj6791 Місяць тому

    How to find the first,last and middle number in an given input in java ,post a video for this ques .The method of teaching in the notebook is easily understandable.Good teaching methodology.

  • @Reahroy-fr4jl
    @Reahroy-fr4jl 5 місяців тому +1

    Thank you so much ❤ please continue to do like these videos❤❤❤

  • @sreejayvlogs
    @sreejayvlogs Рік тому +1

    Awesome bro…. 😊 it’s so clear

  • @mounimouni224
    @mounimouni224 2 роки тому +1

    Detailed one..!! Great Thank you..!!

  • @NailPassion999
    @NailPassion999 Рік тому +1

    Excellent explanation😃

  • @vikrambahure8639
    @vikrambahure8639 8 місяців тому +1

    very easy steps ...thanks sir

  • @kainaatmakhani6550
    @kainaatmakhani6550 3 роки тому +2

    u made my life very easy thankyou so much.

  • @docmusiq
    @docmusiq 2 роки тому +3

    If your loss conversation, just change your temp data type from integer to double...eg declare your temp like: double temp;
    Your explanations are amazing, especially the way you break down the question through pseudo-code and you show every declared variable duty while executing the code...

  • @payalnishad1854
    @payalnishad1854 2 роки тому +1

    Superb bro. 🙏thanks alot for make coding this easy... I was unable to understand the armstorng concept but when I came across your video now I started considering myself pro at coding😝😂👍

  • @ShivaKumar-yy2ym
    @ShivaKumar-yy2ym 3 роки тому +1

    Thank you so munch...
    Great work 👍

  • @mepreetii
    @mepreetii 11 місяців тому +1

    Hi sir you should initialize temp as double as math pow cant be in int data type

  • @sindhuhari2628
    @sindhuhari2628 3 роки тому +1

    Brother there we need to do explicit type conversion near applying power else we will get an lossy conversion error

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому +3

      Yes, students are smart and will figure it out😊, they won't like if I spoon feed everything!
      Thanks for supporting!

    • @Giriagroandfashion
      @Giriagroandfashion 2 роки тому

      How to do Brother??? Can You Please Explain

  • @anusharasumolla3017
    @anusharasumolla3017 5 місяців тому

    Thank you so much your videos helped me a lottttttt

  • @Aishwarya_Shettar
    @Aishwarya_Shettar 3 місяці тому

    Sir,make vdo on
    Find a armstrong number btwn
    2 numbers!

  • @Misartlog_brush
    @Misartlog_brush 2 роки тому

    It was very helpful, thanks

  • @appuappu8466
    @appuappu8466 2 роки тому

    Write a program add two number without using additional operator in java.
    How to sir

  • @antonychellamarul
    @antonychellamarul Рік тому +3

    Sir, *Definition Check*
    An Armstrong number is a positive n-digit number that is equal to the sum of the nth powers of their digits.
    (not only by cubes ,cubes for only 3 digits).
    Ex: 8208 = (8^4 + 2^4 + 0^4 + 8^4) = 8208. *not by cubes* .

    • @BTechComputerScience
      @BTechComputerScience  Рік тому +4

      Yes that's true, this is for beginner level, once u learn this, we can do it for any number of digits. Easy.

  • @sandhyabonagiri8330
    @sandhyabonagiri8330 2 роки тому

    Tq alot bro....🥰🥰🥰🥰

  • @venkatakumargangapatla4510
    @venkatakumargangapatla4510 2 роки тому

    Thank u soo much sir 🤝🤝🤝

  • @saikrishna-fg2so
    @saikrishna-fg2so 2 роки тому +1

    please copy the code in the comment session, it have some errors

  • @ravinatram
    @ravinatram 3 роки тому +1

    Pls give description of variables pls

  • @durgabhavani5855
    @durgabhavani5855 Рік тому

    Sir If u don't mine u r way of explanation is so nyc but u r voice is not audible properly please raise u r voice sir

  • @priyankapatil6521
    @priyankapatil6521 3 роки тому

    Sir ...plz how to generate random number par vedio banao ..

  • @salmanparsi8239
    @salmanparsi8239 3 роки тому

    Very usefull you deserve a like

  • @SourabhPrajapatArts
    @SourabhPrajapatArts 3 роки тому +1

    thanks bro

  • @abdulrahim7763
    @abdulrahim7763 11 місяців тому

    tried without while loop..this is working fine for me (give any number within the limit of integer data type)
    Scanner sc=new Scanner(System.in);

    System.out.println("Enter any number to find out if it is a Armstrong number or not");

    int input=sc.nextInt();

    String s="";
    String count=s.valueOf(input);
    int input_size = count.length();
    int digit;
    double Armstrong=0;
    double result=0;
    int actual=input;

    if(input>0)
    {

    for(int i=1;i

    • @BTechComputerScience
      @BTechComputerScience  11 місяців тому +1

      It's really great that u tried on your own and came up with great logic.😊

  • @sureshirla4283
    @sureshirla4283 2 роки тому

    Sir akkada 153 number iccham kabatti math.(temp 3 ) ani pettaru but asalu ye number ivvakunda Armstrong aa kadha ani telusukovadam ela

  • @vishalrc6903
    @vishalrc6903 2 роки тому

    i get error when i use math.pow conversion type error what to do now

  • @kiranmairuben2978
    @kiranmairuben2978 3 роки тому +2

    Error in
    temp= math.pow(temp, 3);
    pls help

  • @Kishore-xz6cb
    @Kishore-xz6cb 7 місяців тому

    everyone learning the program meanwhile me getting saced in 2am by hearing a brid sound 4:28😂

  • @greeshmikaagarwal256
    @greeshmikaagarwal256 3 роки тому

    Thank you

  • @aishwaryas5146
    @aishwaryas5146 2 роки тому

    Where is execution part?

  • @deamoneye5075
    @deamoneye5075 3 роки тому +2

    Concept is Wrong, Pow(Num,Length) is right .

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому

      Yup.. that's right! But m just teaching the basics.. so that students can understand the core and then move to a little more complex programs where they can mix 'Armstrong' and 'count number of digits of the given number' to perform what you just mentioned

  • @sindhuhari2628
    @sindhuhari2628 3 роки тому

    And why aren't you uploading videos these days

  • @PreethiRenu
    @PreethiRenu Рік тому

    anna ,Armstrong number in a given range in java edhuku coding vanum anna pls video upload 😔pannunga

  • @aishwaryas5146
    @aishwaryas5146 2 роки тому

    @3:05 so many mosquitoes my ears...

  • @StudyPulse-uh7hk
    @StudyPulse-uh7hk Місяць тому

    ❤❤❤

  • @HiteshSote
    @HiteshSote 2 роки тому

    What is about 1634

    • @aishwaryas5146
      @aishwaryas5146 2 роки тому

      Armstrong we will get 308 so answer is not armstrong

  • @mahaperumal5872
    @mahaperumal5872 3 роки тому

    why divided by 10 please any one explain

  • @kiranmairuben2978
    @kiranmairuben2978 3 роки тому

    Error in
    temp= math.pow(temp,3);
    Pls help

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому

      Try importing this - import java.lang.Math;

    • @mohammadsajid8924
      @mohammadsajid8924 3 роки тому

      @@BTechComputerScience kr diya import tb bhi error aarha pls help

    • @bumbada1
      @bumbada1 2 роки тому +1

      @@mohammadsajid8924 if you have stored temp in int that can throw an error
      type cast it : temp= (int) Math.pow(temp,3);

    • @bumbada1
      @bumbada1 2 роки тому

      @@BTechComputerScience explanation: pow method returns a double so if your temp is not double, you need to type cast it

  • @naveena1441
    @naveena1441 3 роки тому

    👍👍👍👍👍👍👍

  • @kainaatmakhani6550
    @kainaatmakhani6550 3 роки тому

    sir plzz make video of palindrome number in java?

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому

      Watch my palindrome for strings video, a good coder like u can easily modify it for numbers 😊

  • @tech-learner4555
    @tech-learner4555 3 роки тому

    How u fix ur cam frmd

    • @BTechComputerScience
      @BTechComputerScience  3 роки тому

      it's a pretty messed up setup right now, previously I was using a phone holder like this one amzn.to/3ArD6YE

    • @tech-learner4555
      @tech-learner4555 3 роки тому

      Thanks 🙏🏻

  • @Chari-007
    @Chari-007 3 роки тому

    👍👏👏👏👏

  • @Giriagroandfashion
    @Giriagroandfashion 2 роки тому

    Getting error at Math.pow line

  • @Solomoon-ce5wx
    @Solomoon-ce5wx 2 роки тому

    Not like it

  • @Swatisirmour
    @Swatisirmour Рік тому

    Too much complicated

    • @BTechComputerScience
      @BTechComputerScience  Рік тому

      Practice more, do more coding... then it might not seem very complicated!

  • @muvvaranjithkumar7260
    @muvvaranjithkumar7260 Рік тому

    thank you bro