Python GrundlagenEinfach

Reichliche Anzahl

Detaillierte Anleitung und Python-Implementierung für das Problem „Abundant Number“.

Problemstellung

Einfach

Schreiben Sie eine Funktion is_abundant(n), die eine positive Ganzzahl n annimmt und True zurückgibt, wenn n eine häufig vorkommende Zahl ist, andernfalls False. Eine reichlich vorhandene Zahl ist eine Zahl, bei der die Summe ihrer eigentlichen Teiler (alle Teiler außer der Zahl selbst) größer als die Zahl ist.

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

Beispiele

Example 1
Input
n = 12
Output
True
Explanation

Proper divisors of 12: 1, 2, 3, 4, 6. Sum = 16. Since 16 > 12, it is abundant.

Example 2
Input
n = 18
Output
True
Explanation

Proper divisors of 18: 1, 2, 3, 6, 9. Sum = 21. Since 21 > 18, it is abundant.

Example 3
Input
n = 7
Output
False
Explanation

Proper divisors of 7: 1. Sum = 1. Since 1 < 7, it is not abundant.

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.