Python GrundlagenEinfach

Automorphe Zahl

Detaillierte Anleitung und Python-Implementierung für das Problem der „automorphen Zahl“.

Problemstellung

Einfach

Schreiben Sie eine Funktion is_automorphic(n), die eine nicht negative Ganzzahl n annimmt und True zurückgibt, wenn n eine automorphe Zahl ist, andernfalls False. Eine automorphe Zahl ist eine Zahl, deren Quadrat mit der Zahl selbst endet. Beispielsweise ist 25 automorph, da 25^2 = 625, was mit 25 endet.

Einschränkungen
  • 0 <= n <= 10^6

Beispiele

Example 1
Input
n = 25
Output
True
Explanation

25^2 = 625. The last two digits of 625 are 25, which matches n.

Example 2
Input
n = 76
Output
True
Explanation

76^2 = 5776. The last two digits of 5776 are 76, which matches n.

Example 3
Input
n = 13
Output
False
Explanation

13^2 = 169. The last two digits of 169 are 69, which does not match 13.

Need a Hint?
Erwägen Sie die Verwendung von Basics-spezifischen Datenstrukturen wie Mengen oder Heaps.
Edge Cases to Watch
  • Leere Eingabestrukturen
  • Einzelelementeingaben
  • Große numerische Grenzen

Bereit zur Lösung?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Im Editor öffnen
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Empfohlene Python-Ressourcen

Erweitern Sie Ihr Wissen mit zugehörigen interaktiven Tutorials, Spickzetteln und Codevergleichen.