I did this as an answre to some common js questions , the question was
Write a function which will return you first two times 1, then 2, then 3, then 5 and so on (Fibonacci numbers). Don't use any global variables.var fibonacci = (function () {
var arr = [0, 1];
return function () {
var num = arr[arr.length - 1],
len = arr.length;
arr.push(arr[len - 1] + arr[len - 2]);
return num;
};
}());
//test
var i;
for (i = 0; i < 10; i++) {
console.log(fibonacci());
}
//1,1,2,3,5,8,13,21,34,55
write an assembly language program to find sum of N numbers
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
write it in 8085
write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html
Write a program which takes any number of days from the user. the program should display the number of years, number of months formed by these days as well as the remaining days.
Exactly what do you mean by 'C program in Java'
#include #include void main(void) { int i,j,k,n; clrscr(); i=0; j=1; printf("%d %d ",i,j); for(n=0;n<=5;n++) { k=i+j; i=j; j=k; printf("%d ",k); } getch(); }
1 2 3
//to generate Fibonacci series upto a range of 200....(in C).... #include<stdio.h> main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i<=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }
Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.
write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)
There isn't much to it:---alert("Hello " + "world!");---'alert' creates a popup, and the + does string concatenation.See related link for a Javascript tutorial.
JavaScript is a scripting language that is mainly used within a web browser. Jquery is a library of javascript code that can be used together with your javascript program. A set of functions that can preform common tasks is provided, which will reduce the amount of code that you have to write yourself.
<html> <head> <script type="text/javascript"> function series() { var i=1 while(i<=10) { document.write(i+"<br>") i=i+2 } } </script> </head> <body> <form action="#" name=f1> <input type=button value="generate series" onclick="series()"> </form> <br><span id="outtab"></span> </body> </html>
write a program to print the series 1/12+1/22+.........+1/n2 ?
#include<iostream> unsigned fib (unsigned term, unsigned a=0, unsigned b=1) { if (term<1) return a; return fib (--term, a+b, a); } int main() { std::cout << "Fibonacci (1000th term): " << fib (1000) << std::endl; }
go to notepad and write Javascript code and save it as .js and then import it into a page with a src tag