Python Temel BilgilerKolay

Mükemmel sayı

'Mükemmel sayı' sorunu için ayrıntılı kılavuz ve Python uygulaması.

Sorun Bildirimi

Kolay

Pozitif bir n tamsayısını alan ve mükemmel bir sayı ise True veya değilse False döndüren bir is_perfect(n) fonksiyonu yazın. Mükemmel bir sayı, uygun bölenlerinin (sayı hariç tüm bölenlerin) toplamına eşit olan bir sayıdır. Örneğin 6 = 1 + 2 + 3.

Kısıtlamalar
  • 1 <= n <= 10^6

Örnekler

Example 1
Input
n = 6
Output
True
Explanation

The proper divisors of 6 are 1, 2, 3. Their sum is 1 + 2 + 3 = 6.

Example 2
Input
n = 28
Output
True
Explanation

The proper divisors of 28 are 1, 2, 4, 7, 14. Their sum is 1 + 2 + 4 + 7 + 14 = 28.

Example 3
Input
n = 12
Output
False
Explanation

The proper divisors of 12 are 1, 2, 3, 4, 6. Their sum is 16, which is not 12.

Need a Hint?
Kümeler veya yığınlar gibi Basics'e özgü veri yapılarını kullanmayı düşünün.
Edge Cases to Watch
  • Boş giriş yapıları
  • Tek eleman girişleri
  • Büyük sayısal sınırlar

Çözmeye Hazır mısınız?

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

Editörde Aç
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

Önerilen Python Kaynakları

İlgili etkileşimli eğitimler, yardımcı sayfalar ve kod karşılaştırmalarıyla bilginizi genişletin.