Skip to content

Instantly share code, notes, and snippets.

@faisalnjs
Last active December 9, 2025 06:54
Show Gist options
  • Select an option

  • Save faisalnjs/1b2ecb034c7fa1f087c3ed2e8955966f to your computer and use it in GitHub Desktop.

Select an option

Save faisalnjs/1b2ecb034c7fa1f087c3ed2e8955966f to your computer and use it in GitHub Desktop.
Expected emission lines from H atom for given series.
// Inputs
var presets = {
lyman: {
initial: 2,
final: 1
},
balmer: {
initial: 3,
final: 2
},
paschen: {
initial: 4,
final: 3
},
brackett: {
initial: 5,
final: 4
},
};
const preset = 'brackett';
var initial = presets[preset].initial;
var final = presets[preset].final;
// Constants
const h = 6.6256e-34;
const c = 3e8;
const R = 1.097e7;
// Formulas
var lambda = 1 / (R * ((1 / (final ** 2)) - (1 / (initial ** 2))));
var E = (h * c) / lambda;
// Outputs
var output = {
series: preset,
initial,
final,
wavelength: {
'm': (lambda * 1e7).toPrecision(4) + '*10^-7m',
'nm': (lambda * 1e7 * 1e2).toPrecision(4) + 'nm',
},
energy: {
'J': (E * 1e18).toPrecision(4) + '*10^-18J',
},
};
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment