+ 1
Code not working
I'm trying to get the highest palindromic number but it's not working, how should I fix it. https://code.sololearn.com/c3tiyYk891U9/?ref=app
3 Respostas
+ 1
Probably because the max method doesn't takes only 1 argument and you have no other method named max(that takes only 1 argument) for a class Math that you are trying to overload , therefore it raises the error ,you need to pass two arguments to max method
0
So i made some changes ,it might not be the best optimized way to do as I have a very little to no understanding of c# but it works for your case
namespace SoloLearn
{
class Program
{
public static int max;
public static int firstNumber=0;
public static int secondNumber;
public static bool getpalindrome( int num )
{
int rem;
int temp = num;
int sum =0;
while (num > 0)
{
rem = num % 10;
num = num / 10;
sum = sum *10+rem;
}
//Console.WriteLine(sum);
return temp == sum;
}
static void high(int thousand)
{
for (int x = 1;x < thousand;x++)
{
if (getpalindrome(x)){
secondNumber=x;
max=Math.Max(firstNumber,secondNumber);
firstNumber=max;
}
}
Console.WriteLine(max);
}
static void Main(string[] args)
{
0
Uh I am wondering if this is Java or c# ,I literally searched for Java related stuff , didn't expect both the languages to be somewhat similar!🙄