Question 44 : Write a program in Java to check whether the number given by the user is a Krishna Murthy number or not.
Krishna Murthy Number : It is a number which is equal to the sum of the factorials of all its digits.
For example : 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145
Java Program :
import java.io.*;
class krishnamurthy
{
int fact(int n)
{
int i,p=1;
for(i=n;i>=1;i--)
p=p*i;
return p;
}
void krishna()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a,b,s=0;
System.out.print("Enter the number : ");
a=Integer.parseInt(br.readLine());
System.out.print("\n");
int n=a;
while(a>0)
{
b=a%10;
s=s+fact(b);
a=a/10;
}
if(s==n)
System.out.print(n+" is a krishnamurthy number");
else
System.out.print(n+" is not a krishnamurthy number");
}
}
Krishna Murthy Number : It is a number which is equal to the sum of the factorials of all its digits.
For example : 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145
Java Program :
import java.io.*;
class krishnamurthy
{
int fact(int n)
{
int i,p=1;
for(i=n;i>=1;i--)
p=p*i;
return p;
}
void krishna()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a,b,s=0;
System.out.print("Enter the number : ");
a=Integer.parseInt(br.readLine());
System.out.print("\n");
int n=a;
while(a>0)
{
b=a%10;
s=s+fact(b);
a=a/10;
}
if(s==n)
System.out.print(n+" is a krishnamurthy number");
else
System.out.print(n+" is not a krishnamurthy number");
}
}
Working Fine... Just make the factorial part within the main...
ReplyDeleteimport java.util.Scanner;
Deletepublic class krishnamurthynumber
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.print("Enter the number : ");
int input,b,sum=0;
input=in.nextInt();
System.out.print("\n");
int n=input;
while(input>0)
{
b=input%10;
int i,fact=1;
for(i=b;i>=1;i--)
fact=fact*i;
sum=sum+fact;
input=input/10;
}
if(sum==n)
System.out.print(n+" is a krishnamurthy number");
else
System.out.print(n+" is Not a krishnamurthy number");
}
}
krisnamurti numbers btween 1 t 1000
ReplyDeletecool part
ReplyDeleteHey can you please help me with String programs for example finding the frequency of each character in the string entered by the user
ReplyDeleteUse length statement as
Deletepublic void main (String s)
int l=s.length();
03216245803
DeleteThis the exact Logic I used in making a friends assignment last week
ReplyDeleteI also used a seperate function for the calculation of factorial
:) :)
This is same as that of the special number right???
ReplyDeleteno!! it is diff... special no. is for ex.135...then 1+3+5=9 and 1*3*5*9=135
Deletebut krishna murthy is sum of the factorials of the numbers
Yes
DeletePublic static int fact(int n)
Deletethank you very much as it has helped me a lot
ReplyDeletethis means special no. do not name with different to confuse us
ReplyDeleteIt would be better if you did the whole under the main function...
ReplyDeletemade the program very tuff.......
ReplyDeletevery tuff to understand
ReplyDeletemake it a little simple
Can you do it using boolean
ReplyDeleteCan u do it using scanner class because it is very hard to understand
ReplyDeleteExclusive solution
ReplyDeleteNice
ReplyDeletejao bsdk
ReplyDeleteChecking if a number is Krishna involves intricate mathematical analysis. My Stream Unwatchable It's an intriguing concept where certain properties are examined.
ReplyDeleteKocaeli
ReplyDeleteDenizli
Bursa
istanbul
Van
EAPF
Adıyaman Lojistik
ReplyDeleteTrabzon Lojistik
Muğla Lojistik
Bayburt Lojistik
Bayburt Lojistik
QDY
4C9C0
ReplyDeleteHatay Lojistik
Adıyaman Parça Eşya Taşıma
Rize Evden Eve Nakliyat
Balıkesir Lojistik
Kütahya Parça Eşya Taşıma
510F4
ReplyDeleteTrabzon Evden Eve Nakliyat
Zonguldak Evden Eve Nakliyat
Çerkezköy Evden Eve Nakliyat
buy anapolon oxymetholone
Manisa Evden Eve Nakliyat
Niğde Evden Eve Nakliyat
buy testosterone propionat
masteron
steroid cycles for sale
95CE8
ReplyDeleteKaraman Evden Eve Nakliyat
Ünye Koltuk Kaplama
Ordu Evden Eve Nakliyat
Sincan Parke Ustası
Batman Parça Eşya Taşıma
Manisa Evden Eve Nakliyat
Malatya Şehirler Arası Nakliyat
Mersin Şehirler Arası Nakliyat
Iğdır Şehir İçi Nakliyat
EEFA7
ReplyDeleteElazığ Evden Eve Nakliyat
Edirne Şehir İçi Nakliyat
Tokat Şehirler Arası Nakliyat
Elazığ Lojistik
Ağrı Şehirler Arası Nakliyat
Karapürçek Boya Ustası
Kocaeli Şehirler Arası Nakliyat
Bartın Lojistik
Ankara Parça Eşya Taşıma
B87E1
ReplyDeleteAdana Şehir İçi Nakliyat
Bartın Şehirler Arası Nakliyat
Mardin Şehirler Arası Nakliyat
Sincan Fayans Ustası
Lovely Coin Hangi Borsada
Maraş Lojistik
Tunceli Şehirler Arası Nakliyat
Tekirdağ Çatı Ustası
Diyarbakır Evden Eve Nakliyat
CA54E
ReplyDeleteDüzce Lojistik
Afyon Şehirler Arası Nakliyat
Düzce Şehir İçi Nakliyat
Bursa Parça Eşya Taşıma
Tokat Evden Eve Nakliyat
Aksaray Evden Eve Nakliyat
Erzincan Lojistik
Mardin Lojistik
Maraş Parça Eşya Taşıma
C7FA1
ReplyDeletebedava sohbet
manisa en iyi ücretsiz sohbet uygulamaları
sohbet odaları
gümüşhane en iyi rastgele görüntülü sohbet
malatya canlı sohbet et
parasız görüntülü sohbet
Kırklareli Telefonda Rastgele Sohbet
zonguldak görüntülü sohbet kızlarla
ardahan sohbet siteleri
BEFCD
ReplyDeletedüzce telefonda rastgele sohbet
sesli sohbet siteleri
kırıkkale ücretsiz sohbet sitesi
chat sohbet
erzincan rastgele görüntülü sohbet uygulaması
kadınlarla rastgele sohbet
Aksaray Chat Sohbet
diyarbakır canli sohbet chat
görüntülü sohbet
18342
ReplyDeletetrezor suite
galagames
zkswap
dexscreener
trezor suite
roninchain
poocoin
solflare
poocoin
2171B
ReplyDeleteŞile
Kazımkarabekir
Bahçelievler
Erzin
Afyonkarahisar
Çaykara
Orta
Burdur
Gömeç
شركة مكافحة الصراصير بالاحساء sZXyBBIwBc
ReplyDelete274C6B8042
ReplyDeletetakipçi satın al
50EFDB5CF1
ReplyDeletegercek turk takipci