Notebook - Welcome to Notebook

Contact/Report Bugs
You can contact me at: bkenwright@xbdev.net

If you list all the natural numbers below 10 that are multiples of 3 or 5 we get 3 5 6 and 9 The sum of these multiples is 23 Find the sum of all the multiples of 3 or 5 below 1000 function findsum val let sum 0 for let i 0 i val i if i 3 0 sum i else if i 5 0 sum i end for return sum end findsum console log under 10 findsum 10 console log under 1000 ans findsum 1000 Each new term in the Fibonacci sequence is generated by adding the previous two terms By starting with 1 and 2 the first 10 terms will be 1 2 3 5 8 13 21 34 55 89 By considering the terms in the Fibonacci sequence whose values do not exceed four million find the sum of the even valued terms function fib v if v 1 return 1 return fib v 1 fib v 2 test fib function console log fib 1 console log fib 2 console log fib 3 console log fib 4 console log fib 5 let sum 0 for let i 0 i 200 i let res fib i if res 4000000 break if res 2 0 sum res end for i console log ans sum The prime factors of 13195 are 5 7 13 and 29 What is the largest prime factor of the number 600851475143 function primefactors n Print the number of 2s that divide n while n 2 0 console lrite 2 n 2 n must be odd at this point So we can skip one element Note i i 2 for let i 3 i Math sqrt n i 2 While i divides n print i and divide n while n i 0 console log i n i This condition is to handle the case whien n is a prime number greater than 2 if n 2 console log n end primefactor console log pf 13195 primefactors 13195 console log pf 600851475143 ans primefactors 600851475143 A palindromic number reads the same both ways The largest palindrome made from the product of two 2 digit numbers is 9009 91x99 Find the largest palindrome made from the product of two 3 digit numbers function palindrome m d let max 0 for let x 1 x m x for let y 1 y m y let res x y let s String res let l s length if l d let found true for let k 0 k l 2 k if s k s l 1 k continue found false k if found console log s if found if res max max res y x return max end palindrome console log test palindrome 99 3 console log ans palindrome 999 4