Step 1: Start
Step 2: Read n
Step 3: Temp=n
Step 4: arm=0
Step 5: If n is not equal to 0,
rem=n%0
arm=arm+(rem*rem*rem)
Step 6: n=n/10, goto 5
Step 7: If n=0, then if temp=arm, print No. is armstrong
Step 8: if temp is not equal to arm print No. is not armstrong
Step 9: Stop
Type your answer here... i think we should first enter 1 number then check it
/*Program to find whether given no. is Armstrong or not. Example : Input - 153 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */ class Armstrong{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); int n = num; //use to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10; check = check + (int)Math.pow(remainder,3); num = num / 10; } if(check == n) System.out.println(n+" is an Armstrong Number"); else System.out.println(n+" is not a Armstrong Number"); } }
a write the algorithm to concatenate two given string
Complexity of an algorithm is a measure of how long an algorithm would take to complete given
The time complexity of a while loop in an algorithm is typically represented as O(n), where n is the number of iterations the loop performs.
A flowchart to find the factorial of a given number typically includes the following steps: Start, read the input number, check if the number is less than 0 (return an error for negative numbers), initialize a result variable to 1, and then use a loop to multiply the result by each integer from 1 to the input number. The algorithm can be summarized as follows: if ( n ) is the input number, initialize ( \text{factorial} = 1 ); for ( i ) from 1 to ( n ), update ( \text{factorial} = \text{factorial} \times i ); finally, output the factorial.
<html> <head> <Script Language="JavaScript"> var a,n,b=0,t; n=parseInt(window.prompt("enter n","0")); t=n; while(n>0) { a=n%10; b=b+a*a*a; n=n/10; } if(b==t) { document.writeln("Armstrong no"); } else { document.writeln("Not an Armstrong no"); } </script> </head> </html>
Algorithm Step1: Read A, B, C Step2: If A > B is True, then check whether A > C, if yes then A is greatest otherwise C is greatest Step3: If A > B is False, then check whether B > C, if yes then B is greatest otherwise C is greatest Give the Flowchart Answer
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
Use a simple DFS/BFS traversal. If you have gone through all nodes, the graph is connected.
45
An Armstrong number (or narcissistic number) is a number that is equal to the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because (1^3 + 5^3 + 3^3 = 153). To find Armstrong numbers in a given range, you can iterate through each number, calculate the sum of its digits raised to the power of the number of digits, and check if it equals the original number. Here's a simple Python code snippet: def is_armstrong(num): digits = [int(d) for d in str(num)] return num == sum(d ** len(digits) for d in digits) # Example usage for i in range(1000): if is_armstrong(i): print(i)