Coder Social home page Coder Social logo

merttalug / armstrongnumber Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3 KB

A program that finds whether a number between 0-1000 that it receives as input from users is an Armstrong number.

License: MIT License

Java 100.00%
java armstrong-number kodluyoruz patika-dev mathematics maths

armstrongnumber's Introduction

ArmstrongNumber

A program that finds whether a number between 0-1000 that it receives as input from users is an Armstrong number. img

What is Armstrong Number?

An n-digit number is called an Armstrong number if the sum of the nth powers of the digits is equal to the number itself.

  • Let's take the number 407 for example. (4^3)+ (0^3)+(7^3) = 64+0+343 = 407. This shows that 407 is an armstrong number.
  • Let's also look at the number 1342. (1^4)+(3^4)+(4^4)+(2^4) =1+81+256+16=354 is not an armstrong number because it is not equal to 1342.
  • 1634=1^4+6^4+3^4+4^4=1+1296+81+256=1634
  • 54748=5^5+4^5+7^5+4^5+8^5=3125+1024+16807+1024+32768=54748

Sample Scope


 tempnumber = number;

        while (tempnumber != 0) {
            tempnumber /= 10;
            digitnumber++;
        }

        tempnumber = number;

        while (tempnumber != 0) {
            digitvalue = tempnumber % 10;
            digitpow = 1;
            for (int i = 1; i <= digitnumber; i++) {
                digitpow *= digitvalue;
            }
            res += digitpow;
            tempnumber /= 10;





armstrongnumber's People

Contributors

merttalug avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.