01 Jun 2023

Return Perfect Number

Taken from DailyCodingProblem

A number is considered perfect if its digits sum to exactly 10.

Given a positive integer n, return the n-th perfect number.

For exmaple, given 1, you should return 19. Given 2, you should return 28.


This is the answer I came up with:

function perfect(n: number): number {
  let digits = [n, 0]
  while (digits[0] + digits[1] !== 10) {
  return Number(digits.join(''))


Solution tested in REPL:


Copyright © Paramdeo Singh · All Rights Reserved · Built with Jekyll

This node last updated November 7, 2023 and is permanently morphing...

Paramdeo Singh Guyana

Generalist. Edgerunner. Riding the wave of consciousness in this treacherous mortal sea.

Technology Design Strategy Literature Personal Blogs
Search Site

Results are from Blog, Link Dumps, and #99Problems