For a given 3 digit number, find whether it is armstrong number or not. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. Return "Yes" if it is a armstrong number else return "No".
NOTE: 371 is an Armstrong number since 3^{3} + 7^{3 }+ 1^{3} = 371
Example 1:
Input: N = 153
Output: "Yes"
Explanation: 153 is an Armstrong number
since 1^{3} + 5^{3 }+ 3^{3} = 153.
Hence answer is "Yes".
Example 2:
Input: N = 370
Output: "Yes"
Explanation: 370 is an Armstrong number
since 3^{3} + 7^{3 }+ 0^{3} = 370.
Hence answer is "Yes".
Your Task:  
You dont need to read input or print anything. Complete the function armstrongNumber() which takes n as input parameter and returns "Yes" if it is a armstrong number else returns "No"..
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
100 ≤ n <1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



#User function Template for python3

class Solution:

    def armstrongNumber (ob, n):

        # code here 

Solutions:
class Solution:

	def armstrongNumber(ob, n):
		x = 0
		n = str(n)
		for i in n:
			x += int(i) ** 3
		if x == int(n):
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		a = n
		while a:
			rem = int(a % 10)
			sum = rem * rem * rem + sum
			a = a / 10
		if int(sum) == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		startNum = n
		res = 0
		while n > 0:
			currDig = n % 10
			res += currDig ** 3
			n = n // 10
		if res == startNum:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def find_cube(self, num):
		return num * num * num

	def armstrongNumber(self, n):
		copy = n
		num = 0
		while n > 0:
			rem = n % 10
			cube = self.find_cube(rem)
			num += cube
			n = n // 10
		if num == copy:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		dup = n
		arm = 0
		while n != 0:
			d = n % 10
			arm = arm + d * d * d
			n = n // 10
		if dup == arm:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		a = n
		sum = 0
		for i in range(n):
			rem = n % 10
			sum += rem ** 3
			n = n // 10
		if sum == a:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		temp = n
		while temp != 0:
			d = temp % 10
			sum = sum + d ** 3
			temp = temp // 10
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		num = str(n)
		count = 0
		for i in range(len(num)):
			count += int(num[i]) ** 3
		if count == n:
			return 'Yes'
		else:
			return 'No'


import math

class Solution:

	def armstrongNumber(ob, n):
		s_s = str(n)
		if int(math.pow(int(s_s[0]), 3) + math.pow(int(s_s[1]), 3) + math.pow(int(s_s[2]), 3)) == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		s = 0
		x = n
		while n > 0:
			s = s + (n % 10) ** 3
			n = int(n / 10)
		return 'Yes' if x == s else 'No'


class Solution:

	def armstrongNumber(ob, n):
		string = str(n)
		string_length = len(string)
		sum = 0
		for i in range(string_length):
			digit = int(string[i])
			sum = digit * digit * digit + sum
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		total = 0
		while n > 0:
			last = n % 10
			total += pow(last, 3)
			n = n // 10
		if temp == total:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		N = n
		(temp, res) = (0, 0)
		while n > 0:
			temp = n % 10
			res = res + temp ** 3
			n = n // 10
		if N == res:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		s = str(n)
		A = [int(x) ** 3 for x in s]
		for i in range(len(A) - 1):
			sum = A[i] + A[i + 1]
			A[i + 1] = sum
		if A[len(A) - 1] == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		sum = 0
		power = len(str(n))
		while temp != 0:
			digit = temp % 10
			sum += digit ** power
			temp = temp // 10
		return 'Yes' if n == sum else 'No'


class Solution:

	def armstrongNumber(ob, n):
		count = 0
		temp = n
		num = n
		while n != 0:
			n = n // 10
			count += 1
		sum1 = 0
		rem = 0
		while temp != 0:
			rem = temp % 10
			sum1 = sum1 + rem ** count
			temp = temp // 10
		if sum1 == num:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		dup = n
		res = 0
		while n:
			ld = n % 10
			n = n // 10
			res = res + ld ** 3
		if res == dup:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		num = n
		rem = 0
		while n > 0:
			digit = n % 10
			rem = rem + digit ** 3
			n = n // 10
		if num == rem:
			b = 'Yes'
			return b
		else:
			c = 'No'
			return c


class Solution:

	def armstrongNumber(self, n):
		num = n
		summ = 0
		while num > 0:
			digit = num % 10
			summ += digit ** 3
			num = num // 10
		if summ == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		if not 100 <= n <= 999:
			return
		return 'Yes' if (n // 100) ** 3 + (n // 10 % 10) ** 3 + (n % 10) ** 3 == n else 'No'


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		c = 0
		while n != 0:
			r = n % 10
			c += pow(r, 3)
			n = n // 10
		if c == temp:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		wno = n
		sum = 0
		while wno > 0:
			dig = wno % 10
			wno = wno // 10
			sum = sum + dig ** 3
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		str1 = str(n)
		strlen = len(str1)
		rem = 0
		for l in str1:
			l = int(l)
			m = pow(l, strlen)
			rem += m
		if n == rem:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		test_num = 0
		org_num = n
		while org_num != 0:
			last_digit = org_num % 10
			test_num += last_digit ** 3
			org_num = int(org_num / 10)
		if test_num == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		c = len(str(n))
		res = 0
		tem = n
		while n:
			res = res + (n % 10) ** c
			n = n // 10
		if res == tem:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, N):
		init = int(N)
		word = str(N)
		sum = 0
		for i in range(len(word)):
			sum = sum + int(word[i]) ** 3
		if init == sum:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		arm = 0
		while temp > 0:
			rem = temp % 10
			arm = arm + rem * rem * rem
			temp = temp // 10
		if n == arm:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		ans = 0
		temp = n
		while n > 0:
			ans += (n % 10) ** 3
			n //= 10
		if ans == temp:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		n = str(n)
		a = int(n[0]) ** 3
		b = int(n[1]) ** 3
		c = int(n[2]) ** 3
		s = a + b + c
		if int(n) == int(s):
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n
		l = []
		while x > 9:
			a = x % 10
			l.append(a)
			x = x // 10
		l.append(x)
		s = 0
		for i in l:
			s += i ** 3
		if s == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		num = 0
		n1 = n
		while n1:
			t = n1 % 10
			n1 = n1 // 10
			num += t * t * t
		if num == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(self, n):
		digits = str(n)
		sum = 0
		for digit in digits:
			sum += int(digit) ** 3
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(self, n):
		temp = n
		sum = 0
		while temp > 0:
			digit = temp % 10
			sum += digit ** 3
			temp //= 10
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		org_nu = n
		temp = n
		digit = 0
		while n > 0:
			n = n // 10
			digit += 1
		sum_of_arms_number = 0
		while temp > 0:
			a = temp % 10
			sum_of_arms_number += pow(a, digit)
			temp = temp // 10
		if sum_of_arms_number == org_nu:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		original = n
		s = 0
		for i in range(n):
			r = n % 10
			s = s + r * r * r
			n = n // 10
		if s == original:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		nc = n
		while nc > 0:
			sum += (nc % 10) ** 3
			nc = nc // 10
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = ''
		N = n
		while n > 0:
			a = n % 10
			n = n // 10
			x += str(a)
		b = 0
		for i in x:
			b += int(i) ** 3
		if b == N:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		r = str(n)
		l = len(r)
		v = 0
		for i in r:
			v += int(i) ** l
		return 'Yes' if v == n else 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n
		arm = 0
		while n != 0:
			last_digit = n % 10
			arm += last_digit ** 3
			n = n // 10
		if arm == x:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		c = n
		count = 0
		while c != 0:
			b = c % 10
			c = c // 10
			count = count + b ** 3
		if count == n:
			return 'Yes'
		return 'No'


import math

class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		num = n
		while num > 0:
			sum += math.pow(num % 10, 3)
			num = num // 10
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		N = n
		while n:
			sum += (n % 10) ** 3
			n //= 10
		if sum == N:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		cpy = n
		sum = 0
		while n > 0:
			rem = n % 10
			sum += rem ** 3
			n = n // 10
		if sum == cpy:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		n = str(n)
		(a, b, c) = map(int, n)
		if pow(a, 3) + pow(b, 3) + pow(c, 3) == int(n):
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = str(n)
		num = 0
		for i in range(len(x)):
			num += int(x[i]) ** len(x)
		if num == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		st = str(n)
		if pow(int(st[0]), 3) + pow(int(st[1]), 3) + pow(int(st[2]), 3) == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		num = n
		remainder = 0
		result = 0
		is_armstrong = 'No'
		while num > 0:
			remainder = num % 10
			num = num // 10
			result = result + remainder ** 3
		if result == n:
			is_armstrong = 'Yes'
		return is_armstrong


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		sum = 0
		r = 0
		while n != 0:
			r = n % 10
			sum += r * r * r
			n = int(n / 10)
		if temp == sum:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n % 10
		y = n // 10
		z = y % 10
		m = y // 10
		o = x ** 3 + z ** 3 + m ** 3
		if o == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sumc = 0
		b = str(n)
		for i in range(len(b)):
			sumc = sumc + pow(int(b[i]), 3)
		if sumc == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		if n == sum((int(x) ** len(str(n)) for x in str(n))):
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		for i in str(n):
			sum = sum + int(i) ** 3
		if sum == n:
			return 'Yes'
		elif sum != n:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		M = str(n)
		L = len(M)
		arm = 0
		for i in range(L):
			arm = int(M[i]) ** L + arm
		if arm == int(M):
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		armNumber = 0
		number = n
		while number > 0:
			rem = number % 10
			armNumber = armNumber + rem ** 3
			number //= 10
		if armNumber == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		revNum = 0
		sum = 0
		initialValue = n
		while n > 0:
			lastDigit = n % 10
			revNum = revNum * 10 + lastDigit
			sum = sum + lastDigit * lastDigit * lastDigit
			n = n // 10
		if sum == initialValue:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n
		s = 0
		while n != 0:
			r = n % 10
			s += r * r * r
			n = n // 10
		if s == x:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		sum = 0
		i = n
		while n > 0:
			sum = sum + n % 10 * (n % 10) * (n % 10)
			n = n // 10
		if sum == i:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		string = str(n)
		if int(string[0]) ** 3 + int(string[1]) ** 3 + int(string[2]) ** 3 == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n
		count = 0
		temp = n
		while temp != 0:
			count += 1
			temp //= 10
		sum_of_power = 0
		while x != 0:
			last_digit = x % 10
			sum_of_power += last_digit ** count
			x //= 10
		if sum_of_power == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		res = 0
		a = n
		while n != 0:
			res += (n % 10) ** 3
			n //= 10
		if res == a:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		x = n
		count = 0
		while x != 0:
			x = x // 10
			count = count + 1
		res = 0
		x = n
		while x:
			res = res + pow(x % 10, count)
			x = x // 10
		if res == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		isArmstrongNumber = 'No'
		sum = 0
		temp = n
		while n > 0:
			remainder = n % 10
			sum = sum + remainder ** 3
			n = int(n / 10)
		if temp == sum:
			isArmstrongNumber = 'Yes'
		return isArmstrongNumber


class Solution:

	def armstrongNumber(ob, n):
		c = 0
		p = str(n)
		for i in range(0, len(p)):
			c += int(p[i]) ** 3
		if c == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		d = n
		c = 0
		i = 0
		while d > 0:
			i = d % 10
			c += pow(i, 3)
			d = d // 10
		if n == c:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		ob = n
		count = 0
		temp = n
		while temp != 0:
			count += 1
			temp //= 10
		sum = 0
		while n != 0:
			rem = n % 10
			n = n // 10
			sum = sum + pow(rem, count)
		if sum == ob:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		s = 0
		temp = n
		while temp > 0:
			rem = temp % 10
			s += rem ** 3
			temp //= 10
		if s == n:
			return 'Yes'
		else:
			return 'No'


import math

class Solution:

	def armstrongNumber(ob, n):
		a = str(n)
		y = 0
		for i in a:
			i = int(i)
			y += i ** 3
		if y == n:
			return 'Yes'
		return 'No'


class Solution:

	def armstrongNumber(ob, n):
		n = str(n)
		sum = 0
		for i in n:
			temp = int(i)
			sum += temp * temp * temp
		if sum == int(n):
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		act = n
		arm = 0
		while n > 0:
			temp = n % 10
			n = n // 10
			arm += temp ** 3
		return 'Yes' if arm == act else 'No'


class Solution:

	def armstrongNumber(ob, n):
		check = 0
		dup = n
		while dup > 0:
			num = dup % 10
			check += num * num * num
			dup = int(dup / 10)
		val = 'No'
		if check == n:
			val = 'Yes'
		return val


class Solution:

	def armstrongNumber(ob, n):
		tmp = n
		ans = 0
		while n > 0:
			rem = n % 10
			ans += rem ** 3
			n = n // 10
		return 'Yes' if tmp == ans else 'No'


class Solution:

	def armstrongNumber(ob, n):
		N = n
		sum = 0
		while N is not 0:
			rem = N % 10
			sum = sum + rem * rem * rem
			N //= 10
		if sum == n:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def armstrongNumber(ob, n):
		temp = n
		a = str(n)
		count = len(a)
		s = 0
		while n > 0:
			lastdigit = n % 10
			n = n // 10
			c = lastdigit ** count
			s += c
		if s == temp:
			return 'Yes'
		return 'No'