理解电子配置和构造原理
公式:electronConfiguration = (atomicNumber) => { if (atomicNumber <= 0 || !Number.isInteger(atomicNumber)) return "原子序数无效"; const orbitals = ['1s', '2s', '2p', '3s', '3p', '4s', '3d', '4p', '5s', '4d', '5p', '6s', '4f', '5d', '6p', '7s', '5f', '6d', '7p']; const electronCapacities = {'s': 2, 'p': 6, 'd': 10, 'f': 14}; let configuration = ''; let remainingElectrons = atomicNumber; for (let orbital of orbitals) { const orbitalType = orbital[1]; const capacity = electronCapacities[orbitalType]; if (remainingElectrons > capacity) { configuration += `${orbital}${capacity} `; remainingElectrons -= capacity; } else { configuration += `${orbital}${remainingElectrons} `; break; } } return configuration.trim();