diff --git a/855447/Sum of Digits Digital Root.cpp b/855447/Sum of Digits Digital Root.cpp new file mode 100644 index 0000000..5896c56 --- /dev/null +++ b/855447/Sum of Digits Digital Root.cpp @@ -0,0 +1,19 @@ +using namespace std; +int digital_root(int n) +{ + int num; + num=0; + while(true){ + if (n/10!=0){ + num+=n%10; + n=n/10; + }else if ((n+num)>10){ + n+=num; + num=0; + }else if ((n+num)<10) { + num+=n; + break; + } +} + return num; +} \ No newline at end of file diff --git a/855447/find-the-odd-int.cpp b/855447/find-the-odd-int.cpp new file mode 100644 index 0000000..d50ccec --- /dev/null +++ b/855447/find-the-odd-int.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int findOdd(const vector numbers){ + int x = 0,ans = 0; + for(int i = 0 ; i < numbers.size() ; i++){ + x=0; + for (int j = 0 ;j < numbers.size() ; j++){ + if (numbers[i] == numbers[j]){ + x += 1; + } + } + if (x % 2 != 0){ + ans=numbers[i]; + } + } +return ans; +} \ No newline at end of file