I really don’t know just trying to solve a problem


This above question now time is 7:37 I took like 20min to understand 🤣😂
I haven’t had practice coding questions like this I am a web developer not a coding freek.
my code solution for now is incomplete but let’s try this out
using System;using System.Collections.Generic;using System.IO;class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int total=int.Parse(Console.ReadLine()); for(int i=0;i<total;i++){ int number=int.Parse(Console.ReadLine().Split(‘ ‘)[0]); Console.WriteLine(calculate(number)); } } static int calculate(int number){ return f(number); } static int f(int n){ int sum=0; while(n>0){ sum+=n%10; n=n/10; } return sum; } }
Draft At 8:06PM I ate and then started 10min back
using System;using System.Collections.Generic;using System.IO;
class Solution {
static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
int total=int.Parse(Console.ReadLine());
for(int i=0;i<total;i++){
int number=int.Parse(Console.ReadLine().Split(‘ ‘)[0]);
Console.WriteLine(calculate(number));
} }
static int calculate(int number){ return f(number); }
static int g(int n){ i=0;
while(sf(f(n))!=sf(f(i))){ i++; }
return i; }
static int sigmat(int n){
int sum=0;
for(int i=1;i<=n;i++){ sum+=sg(i); } }
static int sg(int n){ return sf(n); }
static int f(int n){
int sum=0;
while(n>0){
int sumA=n%10;
int factorial=1;
while(sumA>1){ factorial*=(sumA–); }
sum+=factorial; n=n/10; }
return sum; }
static int sf(int n){
int sum=0; while(n>0){ sum+=n%10; n=n/10; }
return sum; } }
sorry I should provide this in a code block mostly so it will look nicer next update I will do that.
Finally Solved with below code
