Python Nozioni di baseFacile

Numero abbondante

Guida dettagliata e implementazione Python per il problema del "numero abbondante".

Dichiarazione del problema

Facile

Scrivi una funzione is_abundant(n) che accetta un intero positivo n e restituisce True se n è un numero abbondante, o False altrimenti. Un numero abbondante è un numero in cui la somma dei suoi divisori propri (tutti i divisori escluso il numero stesso) è maggiore del numero stesso.

Vincoli
  • 1 <= n <= 10^6

Esempi

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?
Prendi in considerazione l'utilizzo di strutture dati specifiche di Basics come set o heap.
Edge Cases to Watch
  • Strutture di input vuote
  • Ingressi a elemento singolo
  • Grandi limiti numerici

Pronto a risolvere?

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

Apri nell'editor
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

Risorse Python consigliate

Espandi le tue conoscenze con tutorial interattivi, foglietti illustrativi e confronti di codici correlati.