Quotes help make search much faster. Example: "Practice Makes Perfect"

Showing posts with label Math Problems. Show all posts
Showing posts with label Math Problems. Show all posts

Monday, February 4, 2013

Math Problems: Finding a Product

Script solution for finding a product problem:

Answer: 30

console.log("----------------------------------");
function somfun(a,b,c){
var num = ((a*b)-1)*((b*c)-1)*((c*a)-1);
var den = a*b*c;
if(num % den === 0){
return true;
} else {
return false;
}
}

var max=100;
for(var i=2; i<=max; i++){
for(var j=2; j<=max; j++){
for(var k=2; k<=max; k++){
if(somfun(i,j,k)){
var temp = i*j*k;
console.log(i+" "+j+" "+k+" "+temp);
}
}
}
}

Math Problem: Square Root Sums

Question:

How many pairs of integers (x,y) will satisfy the following equation:
sqrt(x) + sqrt(y) = sqrt(432)

Answer: 13

Solution: Solved using the script below


console.log("----------------------------------");
function comp(a,b){
var temp = Math.sqrt(a)+Math.sqrt(b);
if(temp == Math.sqrt(432)){
return true;
} else {
return false;
}
}
var max=10000;
var count=0;
for(var i=0; i<max; i++){
for(var j=0; j<max; j++){
var temp=comp(i,j);
if(temp){
console.log(i+" "+j);
count++;
}
}
}
console.log("count is " + count);

Sunday, February 3, 2013

Math Problem: Cutting a Plane with X Lines

Question: What is the maximum number of regions a plane can be cut into by an X number of lines

Answer: number of regions = 0.5 * ( x^2 + x + 2)

So, for example, if we have 9 lines, the maximum number of regions the plane would be divided into is 46.

Sunday, January 27, 2013

Math Problems: Function Perfect Square

Question: What is the sum of all positive integers that will allow the evaluated function  f(x) = x^2 + 19x + 130 to be a perfect square?

Answer: 33

Solved using the script below:


console.log("*************************************")
function isInt(value) {
    return !isNaN(parseInt(value,10)) && (parseFloat(value,10) == parseInt(value,10));
}

function someF(x){
return (x*x)+(19*x)+130;
}
var max=100000;
for(var i=0; i<max; i++){
temp = someF(i);
temp2 = Math.sqrt(temp);
if(isInt(temp2)){
console.log("i:"+i+" someFunc:"+temp+" sqrt:"+temp2);
}
}

Math Problems: Minimize the fraction

Problem:
The task is to minimize the value of the fraction x/f(x) where x is any 3-digit number and f(x) is its digits sum. What is the 3-digit number that satisfies these conditions?

Answer: 199

Solved using the script below


console.log("*************************************")
var min=100;
for(var i=0; i<1000; i++){
if(i>=100){
var temp = i.toString();
var hun = parseInt(temp[0]);
var ten = parseInt(temp[1]);
var one = parseInt(temp[2]);
var digsum = hun+ten+one;
var frac = i/digsum;
if(frac<min){
console.log(i+" "+digsum+" "+frac);
min=frac;
}
}
}
console.log("min is "+min);

Math Problems: Collatz Function

Problem:

The Collatz function is defined as f(n) = 3n+1 for odd values of n and f(n) = n/2 for even values of n. What is the smallest possible value of n for which f^7(n) is equal to 5.

Answer: 17

Solution: Solved using the script below:


console.log("*********************************");
function collatz(x){
if(x%2===0){
return x/2;
}
else{
return (3*x)+1;
}
}
var max=1000;
for(var i=0; i<max; i++){
var temp = collatz(collatz(collatz(collatz(collatz(collatz(collatz(i)))))));
if(temp===5){
console.log("i: "+i+" temp: "+temp);
}
}

Math Problems: Sum of two-digit numbers

Question:

If we sum all two digit numbers whose digits are made up of combinations of the numbers 1, 2, 3, 4, what is the result?

Answer: 440

Solution: Solved using the script below


console.log("*********************************");
function cati(string, index){
if(string.charAt(index)==='1' || string.charAt(index)==='2' || string.charAt(index)==='3' || string.charAt(index)==='4'){
return true;
}
else {
return false;
}
}

var sum=0;
for(var i=0; i<100; i++){
if(i>=10){
var temp = i.toString();
if(cati(temp,0) && cati(temp,1)){
console.log(temp);
sum+=i;
}
}
}
console.log("Sum is "+sum);

Math Problems: 5-digit Palindromes

Question:

How many five digit palindromes are there?

Answer: 900

Solution: Solved using the script below


console.log("*********************************");
var count=0;
for(var i=0; i<100000; i++){
if(i>=10000){
var temp = i.toString();
if(temp.charAt(0)===temp.charAt(4) && temp.charAt(1)===temp.charAt(3)){
console.log(temp);
count++;
}
}
}
console.log("Count is "+count);

Math Problems: Union and Intersection

Problem:

If set A has X elements, set B has Y elements and A U B (read A union B) has Z elements, how many elements does A ∩ B (read A intersection B) have?

Answer:

Since

A U B = A + B - (A ∩ B)

Then,

A ∩ B = A + B - (A U B)
elements in A ∩ B = X + Y - Z

Thursday, January 24, 2013

Math Problems: A polynomial f(n) satisfies the equation...

Problem:

A polynomial f(n) satisfies the equation n^3 + 3n^2 + 3n + 1 = 2(f(n+1)) - f(n). Solve for f(10).

Answer: 777

Since the highest order is 3, we can assume that our function f(n) has the form
an^3 + bn^2 + cn + d

and 2(f(n+1)) has the form
2[a(n+1)^3 + b(n+1)^2 + c(n+1) + d]

After expanding, we can compare the coefficients on the left hand side with those on the right hand side:
a = 1
6a+b = 3, b = -3
6a+4b+c = 3, c = 9
2a + 2b + 2c + d = 1, d =-13

so f(n) = n^3 - 3n^2 + 9n - 13
Substitute a value of 10 for n will result in 777.



Tuesday, January 22, 2013

Math Problems: Distinct Possible Sums


Question:
Given an array containing consecutive numbers from 1 to 16, how many sets of 3-number combinations exist where the sum of the three numbers is unique. The numbers in each set also have to be unique. For example, (1,1,16) is not allowed since 1 is repeated.

Answer: 40
Solved using the script below

console.log("*******************************");
var somearray = [];
for(var i=5; i<=50; i+=3){
//console.log(i);
somearray.push(i);
}
console.log(somearray);
var count=0;
var sumarray=[];
for(var i=0; i<somearray.length; i++){
for(var j=0; j<somearray.length; j++){
for(var k=0; k<somearray.length; k++){
if(i!==j && j!==k && k!==i){
var sum = somearray[i]+somearray[j]+somearray[k];
if(sumarray.indexOf(sum)<0){
sumarray.push(sum);
console.log(somearray[i]+" "+somearray[j]+" "+somearray[k]+" "+sum);
count++;
}
}
}
}
}
console.log("count is "+ count);

Math Problems: a+b+c

Question:
If the numbers a, b, and c are multiplied as abc, and the result is 100 and if (a^(log a / log 10)) * (b^(log b / log 10)) * (c^(log c / log 10)) >= 10000, what is the sum, a + bc?

Answer: 102

Solved using the script below which results in the only combination, 1, 1 and 100:


console.log("*******************************");
function log10(val){
return Math.log(val)/Math.LN10;
}

function aloga(x){
return Math.pow(x,log10(x));
}

var max = 200;
for(var i=1; i<=max; i++){
for(var j=1; j<=max; j++){
for(var k=1; k<=max; k++){
temp = aloga(i)*aloga(j)*aloga(k);
if(i*j*k===100 && temp>=10000){
console.log(i+" "+j+" "+k+" "+temp);
}
}
}
}

Monday, January 21, 2013

Math Problems: Digit Sum

Question:
How many numbers between 1000 and 9999 satisfy the condition that the thousands digit is equal to the sum of the hundreds, tens and ones digit?

Answer: 219

Solution: Solved using the script below


console.log("*************************************")
var count=0;
for(var i=0; i<10000; i++){
if(i>=1000){
var temp = i.toString();
tho = parseInt(temp[0]);
hun = parseInt(temp[1]);
ten = parseInt(temp[2]);
one = parseInt(temp[3]);
if(tho === hun+ten+one){
console.log(tho+" "+hun+" "+ten+" "+one);
count++;
}
}
}
console.log("count is "+count);


Thursday, January 17, 2013

Math Problems: How Many Three Digit Numbers?

Question:

How many three digit numbers are there such that the hundreds digit is less than or equal to the tens digit and the ones digit is less than or equal to the tens digit?

Answer: 330

Solved using the script below:


console.log("***************************************");
function threeDigitNum(a,b,c){
return a*100 + b*10 + c*1;
}

var count=0;
for(var i=0; i<=9; i++){
for(var j=0; j<=9; j++){
for(var k=0; k<=9; k++){
var temp = threeDigitNum(i,j,k);
if(i<=j && k<=j && temp>=100){
console.log("i: "+i+" j: "+j+" k: "+k+" num:"+temp);
count++;
}
}
}
}

console.log("count is "+count);

Tuesday, January 15, 2013

Brahmagupta's Formula For Quadrilateral Area


Question: What is the area of a quadrilateral with sides equal to 18, 22, 39, and 41 respectively?

Answer: 798

console.log("********************************");
function Brahmagupta(a,b,c,d){
var perimeter=a+b+c+d;
var s = perimeter/2;
return Math.sqrt((s-a)*(s-b)*(s-c)*(s-d));
}
console.log(Brahmagupta(18,22,39,41));

Math Problems: x^2+2

Question: If a function is f(x) = x^2+2, what is the product of f(x1)*f(x2)*f(x3)*f(x4)? The values of x1 to x4 are as follows.


x1 = 0.27702;
x2 = -0.30596;
x3 = -1.96758;
x4 = 5.99652;

Answer: 969

Solved using the script below:


console.log("********************************");
function func(x){
return Math.pow(x,2)+2;
}
X1 = 0.27702;
X2 = -0.30596;
X3 = -1.96758;
X4 = 5.99652;

product=func(X1)*func(X2)*func(X3)*func(X4);

console.log(product);

Math Problems x^4+64

Question: What is the equivalent fraction of the expression below?

(8^4+64)(16^4+64)(24^4+64)(32^4+64)(40^4+64)(48^4+64)(56^4+64)(64^4+64)
----------------------------------------------------------------------------------------
(4^4+64)(12^4+64)(20^4+64)(28^4+64)(36^4+64)(44^4+64)(52^4+64)(60^4+64)
(84+64)(164+64)(244+64)(324+64)(404+64)(484+64)(564+64)(644+64)(44+64)(124+64)(204+64)(284+64)(364+64)(444+64)(524+64)(604+64)
(84+64)(164+64)(244+64)(324+64)(404+64)(484+64)(564+64)(644+64)(44+64)(124+64)(204+64)(284+64)(364+64)(444+64)(524+64)(604+64)

Answer: 545

Solved using the script below:


console.log("********************************");
function func(x){
return Math.pow(x,4)+64;
}
var numproduct=1;
for(var i=8; i<=64; i+=8){
var temp = func(i);
console.log(i+" "+temp);
numproduct *= temp;
}

var denproduct=1;
for(var i=4; i<=60; i+=8){
var temp = func(i);
console.log(i+" "+temp);
denproduct *= temp;
}

console.log(numproduct/denproduct);

Monday, January 7, 2013

Math Problems: (x^2−17*x+71)^(x^2−34*x+240)=1

Question:

What is the sum of all integer solutions to the following equation?

(x^2−17*x+71)^(x^2−34*x+240)=1

Answer: 49

Solved using the script below resulting in 7, 8, 10 and 24 as possible integer solutions for the equation


function func1(x){
return (Math.pow(x,2)-(17*x)+71);
}

function func2(x){
return (Math.pow(x,2)-(34*x)+240);
}

console.log("**************************************");
var max=10000000;
for(var a=-max; a<=max; a++){
var temp1 = func1(a);
var temp2 = func2(a);
if(temp1==1 || temp2==0 || (temp1==-1 && temp2%2==0)){
console.log("a: "+a+" temp1: "+temp1+" temp2: "+temp2);
}
}

Math Problems: (x^3+x+1)^8

What would be the coefficients of the expanded form of (x^3+x+1)^8?

Answer:

x^24 + 8x^22 + 8x^21 + 28x^20 + 56x^19 + 84x^18 + 168x^17 + 238x^16 + 336x^15 + 476x^14 + 560x^13 + 658x^12 + 728x^11 + 708x^10 + 672x^9 + 589x^8 + 456x^7 + 336x^6 + 224x^5 + 126x^4 + 64x^3 + 28x^2 + 8x + 1

Sunday, January 6, 2013

Math Problems: Arithmetic Progression with Perfect Square Terms


Question:
Find the number of increasing arithmetic progressions of length three, whose terms can range from 1 to 1000. The terms must consist entirely of perfect squares.

Answer: 7

Solved using the script below which resulted in the following arithmetic progressions:

1 25 49
4 100 196
9 225 441
16 400 784
49 169 289
49 289 529
289 625 961


function isInt(value) {
    return !isNaN(parseInt(value,10)) && (parseFloat(value,10) == parseInt(value,10));
}

function isPerfectSquare(value){
if(isInt(Math.sqrt(value))){
return true;
} else {
return false;
}
}

console.log("**************************************");
var max = 1000;
for(var a=1; a<=max; a++){
for(var b=1; b<=max; b++){
for(var c=1; c<=max; c++){
if(b-a==c-b && a<b && b<c && isPerfectSquare(a) && isPerfectSquare(b) && isPerfectSquare(c)){
console.log(""+a+" "+b+" "+c+"");
}
}
}
}

This is an example of scrolling text using Javascript.

Popular Posts