Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Tuesday, 2 April 2013

Check Armstrong Number in Java Programming


Armstrong Number : A number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.
For example 153 is an Armstrong number since 1*1*1 + 5*5*5 + 3*3*3 = 153
In Java Programming We design a code which determine whether given number is Armstrong Number or Not.


Source Code :



<pre class="brush: java">
class arm
{int armstrong(int n)
{
if(n==0)
return n;
else 
return (n%10)*(n%10)*(n%10)+armstrong(n/10);
}
public static void main(String ar[])
{
arm a=new arm();
int x,y=153;
x=a.armstrong(y);
if(x==y)
{
System.out.println("Given  No. "+y+" is a Armstrong No.");
}
else
{
System.out.println("Given  No. "+y+" is Not a Armstrong No.");
}
}
}
</pre>



Output :




Saturday, 5 January 2013

CodingTalks - Sharpen Your Programming Skills

Welcome to Coding Talks.



Coding Talks a platform which programmer can talk with programmers. Our main tarket to provide programming solution like Discussion , Tutorial , Projects Help Etc.

We ll help to improve your programming Skills.