Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

armstrong number program in typescript

let array :number[] = [105, 5, 293, 153, 17, 8208, 2, 1, 371, 95, 407, 54748];
//to find ARMSTRONG NUMBERS IN ARRAY
let armstrong = (num:number) => {
let arm:number = num;
let a:number=arm;
let digits:number = arm.toString().length;
let rem:number=0,temp:number=0;
while(arm>0){
    rem=arm%10;
    temp=temp+(Math.pow(rem,digits));   
    arm=Math.floor(arm/10);
}
if(temp==a) return true;}

let armArray:number[]=array.filter(armstrong);
console.log(armArray);
Comment

PREVIOUS NEXT
Code Example
Typescript :: tweepy stream tweets from user 
Typescript :: ts remove first 0 number from string 
Typescript :: mongodb array not equal to value 
Typescript :: what does lts stand for 
Typescript :: how to check typescript version for my react-app 
Typescript :: angular reload component 
Typescript :: ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none) ERROR: No matching distribution found for mediapipe 
Typescript :: ion datetime time current set 
Typescript :: how to route to another page in angular 
Typescript :: add redux to react typescript 
Typescript :: powershell script remove directory recursive 
Typescript :: typscript to string 
Typescript :: how to erase elemts accoding to index c++ 
Typescript :: typescript get all enum values 
Typescript :: number of digits in a number python 
Typescript :: fetch in ts 
Typescript :: mysqli_fetch_array() expects parameter 1 to be mysqli_result 
Typescript :: list all commits before rebase 
Typescript :: html download tag not working 
Typescript :: how to check if a string is composed only of alphabets in python 
Typescript :: angular jasmine mock http request 
Typescript :: declare jquery in typescript 
Typescript :: if shorthand typescript 
Typescript :: ionic scroll to item programmatically 
Typescript :: angular 13 component example 
Typescript :: react native typescript template not working 
Typescript :: query orders by products woocommerce 
Typescript :: type casting in typescript 
Typescript :: append contents of one file to another 
Typescript :: pass class to generic typescript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =