#python
g=int(input(“enter the number”))
amg=g
sum=0
while amg!=0:
a=amg%10
b=a**3
amg=amg//10
sum=sum+b
if g==sum:
print(sum,”its an amstrong”)
else:
print(sum,”not amstrong”)
num = int(input())
numvalue=num
arr = []
while num > 0:
l = num % 10
num = num – l
arr.append(l)
num = num // 10
res = 0
for i in arr:
p = 1
for j in range(len(arr)):
p = p * i
res+=p
if(res==numvalue):
print(“Yes”)
else:
print(“no”)
void armstrong(int a, int count)
{
int demo = a;
int sum = 0, digit1;
while (a > 0)
{
digit1 = a % 10;
sum = sum + pow(digit1, count);
a = a / 10;
}
if (sum == demo)
{
printf(“yes”);
}
else
{
printf(“no”);
}
}
void main()
{
int num, digit, count = 0, n;
printf(“please enter the num: “);
scanf(“%d”, &num);
int demonum = num;
while (num > 0)
{
digit = num % 10;
count++;
num = num / 10;
}
armstrong(demonum, count);
}
********************************very easy c++ program**************************
#include
#include
using namespace std;
int main()
{
int origNum, num, rem,count=0;
cout <> origNum;
num = origNum;
while(num != 0)
{
rem = num % 10;
num /= 10;
count++;
}
num=origNum;
rem=1;
int sum=0;
u gave in a different process.
for armstrong there is a method to execute.please provide as easy as possible.it is a loss for the paid material members like me
#include
#include
int sum_of_digit(int);
int main()
{
char num[20];
int l,j,res=0,sum=0;
gets(num);
l=strlen(num);
for(int i=0;i0)
{
m=sum%10;
store=store+m;
sum=sum/10;
}
return store;
}
#python
g=int(input(“enter the number”))
amg=g
sum=0
while amg!=0:
a=amg%10
b=a**3
amg=amg//10
sum=sum+b
if g==sum:
print(sum,”its an amstrong”)
else:
print(sum,”not amstrong”)
#include
int main() {
int num,n;
int sum=0,i,rem;
scanf(“%d”,&num);
scanf(“%d”,&n);
int temp=num;
for(i=1;i<=n;i++){
rem=num%10;
sum=sum+(rem*rem*rem);
num=num/10;
}
if(sum==temp){
printf("Its a armstrong number");
}
else{
printf("Its not a armstrong number");
}
return 0;
}
#python3
def armstrong(s):
return sum([int(i)**len(str(s)) for i in str(s)])==s
num=int(input(‘enter the number:\t’))
print(armstrong(num))
num = int(input())
numvalue=num
arr = []
while num > 0:
l = num % 10
num = num – l
arr.append(l)
num = num // 10
res = 0
for i in arr:
p = 1
for j in range(len(arr)):
p = p * i
res+=p
if(res==numvalue):
print(“Yes”)
else:
print(“no”)
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
String s1=s.nextLine();
String[] s2=s1.split(“”);
int j=0;
int[] arr=new int[s2.length];
for(String i:s2) {
arr[j]=Integer.parseInt(i);
j+=1;
}
int sum=0;
int prod=1;
for(int i:arr) {
prod=1;
for(int k =0;k<arr.length;k++) {
prod=prod*i;
}
sum=sum+prod;
}
if(sum==Integer.parseInt(s1)) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
String s1=s.nextLine();
String[] s2=s1.split(“”);
int j=0;
int[] arr=new int[s2.length];
for(String i:s2) {
arr[j]=Integer.parseInt(i);
j+=1;
}
int sum=0;
for(int i:arr) {
sum=sum+(i*i*i);
}
if(sum==Integer.parseInt(s1)) {
System.out.println(“YES”);
}else {
System.out.println(“NO”);
}
}
public class ArmstrongNumber {
public static void main(String[] args) {
System.out.println(checkArmstrong(153));
System.out.println(checkArmstrong(1253));
}
static boolean checkArmstrong(int number) {
int temp = number;boolean isArmstrong = false;
int sum = 0;
while (temp > 0) {
int remainder = temp % 10;
sum += (int)Math.pow(remainder, Integer.toString(number).length());
temp /= 10;
}
if(sum == number) {
isArmstrong = true;
}
return isArmstrong;
}
}
public class ArmstrongNumber {
public static void main(String[] args) {
System.out.println(checkArmstrong(153));
System.out.println(checkArmstrong(1253));
}
static boolean checkArmstrong(int number) {
int temp = number;boolean isArmstrong = false;
int sum = 0;
while (temp > 0) {
int remainder = temp % 10;
sum += remainder*remainder*remainder;
temp /= 10;
}
if(sum == number) {
isArmstrong = true;
}
return isArmstrong;
}
}
#include
#include
void armstrong(int a, int count)
{
int demo = a;
int sum = 0, digit1;
while (a > 0)
{
digit1 = a % 10;
sum = sum + pow(digit1, count);
a = a / 10;
}
if (sum == demo)
{
printf(“yes”);
}
else
{
printf(“no”);
}
}
void main()
{
int num, digit, count = 0, n;
printf(“please enter the num: “);
scanf(“%d”, &num);
int demonum = num;
while (num > 0)
{
digit = num % 10;
count++;
num = num / 10;
}
armstrong(demonum, count);
}
********************************very easy c++ program**************************
#include
#include
using namespace std;
int main()
{
int origNum, num, rem,count=0;
cout <> origNum;
num = origNum;
while(num != 0)
{
rem = num % 10;
num /= 10;
count++;
}
num=origNum;
rem=1;
int sum=0;
while(num!=0)
{rem=num%10;
sum=sum+pow(rem,count);
num /= 10;
}
if(sum==origNum)
{
cout<<"armstrong no";
}
}
u gave in a different process.
for armstrong there is a method to execute.please provide as easy as possible.it is a loss for the paid material members like me
# python 🙂 Meghana
n=int(input())
y=len(str(n))
temp==n
x=0
while(n>0):
a=n%10
x=x+pow(a,y)
n=n//10
if(temp==x):
print(f”YES {temp} is a Armstrong Number”)
else:
print(f”NO {temp} is a Armstrong Number”)