how to add up all the numbers in between 0 and that number
function addUp(num) {
if (num === 1) return 1;
return num + addUp(num - 1);
}
how to add up all the numbers in between 0 and that number
function addUp(num) {
if (num === 1) return 1;
return num + addUp(num - 1);
}
how to add up all the numbers in between 0 and that number
function solution(number){
var sum = 0;
for(var i = 1;i< number; i++){
if(i % 3 == 0 || i % 5 == 0){
sum += i
}
}
return sum;
}
Sum of natural numbers from 1 to 100
TITLE "TO PRINT THE SUM OF NATURAL NUMBERS FROM 1 TO 100"
.MODEL SMALL
.STACK
.DATA
VAL DB 1
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
MOV BX,1
MOV CX,100
MOV AX,0
TOP:
ADD AX,BX
INC BX
LOOP TOP
XOR DX,DX
MOV BX,100
DIV BX
AAM
ADD AX,3030H
PUSH DX
MOV DH,AL
MOV DL,AH
MOV AH,02H
INT 21H
MOV DL,DH
MOV AH,02H
INT 21H
POP AX
AAM
ADD AX,3030H
PUSH DX
MOV DH,AL
MOV DL,AH
MOV AH,02H
INT 21H
MOV DL,DH
MOV AH,02H
INT 21H
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us