JavaScript Lab 3


// Print prime Numbers...
let range = 1;


while (range < 10) {

    let count = 0; 
    for (let i = 1; i <= range ; i++) {
        if (range % i == 0) {
            count++;
        }
    }
    if (count == 2) {
        console.log(range);
    }
    range++;
}



// Printing Star patten

for (let i = 1; i <= 5; i++) {
    console.log(new Array(i + 1).join("*"));
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab 3

SQL Lab 6