generate functionThu, 22 Dec 2022

write a function to receive a whole number and return true if the digits are in ascending order from right to left do not use string

public static bool AscendingDigits(int n) { // 12345 // 12345 int prev = int.MinValue; while (n != 0) { int remainder = n % 10; if (prev <= remainder) { prev = remainder; n = n / 10; } else { return false; } } return true; }

Questions about programming?Chat with your personal AI assistant