From 690d5fcc26d08e86a58198669f9cabfe8f0f78cf Mon Sep 17 00:00:00 2001 From: jatin-singh-kushwaha <164042889+jatin-singh-kushwaha@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:00:38 +0530 Subject: [PATCH] Create ArmstrongRecursion.cpp --- ArmstrongRecursion.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ArmstrongRecursion.cpp diff --git a/ArmstrongRecursion.cpp b/ArmstrongRecursion.cpp new file mode 100644 index 0000000..6255e3d --- /dev/null +++ b/ArmstrongRecursion.cpp @@ -0,0 +1,32 @@ +// given num is armstrong num or not + +#include +#include +using namespace std; + +int f(int n,int d){ + if(n==0) return 0; + return (pow(n%10,d)+f(n/10,d)); + +} +int main(){ + int n,d; + cout<<"Enter the num to check"<>n; + int no_of_digits=0; + int temp=n; + while(temp>0){ + temp/=10; + no_of_digits++; + } + d=no_of_digits; + int result=f(n,d); + if(n==result){ + cout<<"yes"<