diff --git a/Factorial.java b/Factorial.java index d534eee..9cad321 100644 --- a/Factorial.java +++ b/Factorial.java @@ -1,8 +1,10 @@ +// Java program to find factorial of a number import java.util.Scanner; -public class Factorial{ +public class Factorial +{ public static void main(String[] args){ - Scanner sc=new Scanner(System.in); + Scanner sc = new Scanner(System.in); int n=sc.nextInt(); System.out.println(factorial(n)); } diff --git a/armstrong.py b/armstrong.py new file mode 100644 index 0000000..a988381 --- /dev/null +++ b/armstrong.py @@ -0,0 +1,20 @@ +# Python program to check if the number is an Armstrong number or not + +# take input from the user +num = int(input("Enter a number: ")) + +# initialize sum +sum = 0 + +# find the sum of the cube of each digit +temp = num +while temp > 0: + digit = temp % 10 + sum += digit ** 3 + temp //= 10 + +# display the result +if num == sum: + print(num,"is an Armstrong number") +else: + print(num,"is not an Armstrong number") diff --git a/digit.c b/digit.c new file mode 100644 index 0000000..8f653af --- /dev/null +++ b/digit.c @@ -0,0 +1,16 @@ +#include +int main() +{ + int n; // variable declaration + int count=0; // variable declaration + printf("Enter a number"); + scanf("%d",&n); + while(n!=0) + { + n=n/10; + count++; + } + + printf("\nThe number of digits in an integer is : %d",count); + return 0; +} diff --git a/palindrome.java b/palindrome.java new file mode 100644 index 0000000..b8eb4d3 --- /dev/null +++ b/palindrome.java @@ -0,0 +1,22 @@ +//JAVA program to check palindrome number +public class Palindrome +{ + public static void main(String args[]) + { + + int r,sum=0,temp; + int n=454;//It is the number variable to be checked for palindrome + + temp=n; + while( n>0 ) + { + r=n%10; //getting remainder + sum=(sum*10)+r; + n=n/10; + } + if(temp==sum) + System.out.println("palindrome number "); + else + System.out.println("not palindrome"); + } +}