What is the
value of the first triangle number to have over 499 divisors? Show the value
using C or C++ or JAVA.
Hints:
A. Triangular numbers are numbers
that create triangles. In other words 1, 3, 6, 10, 15, 21, etc.
B. Triangular numbers can be
calculated by 1, 1+2, 1+2+3, 1+2+3+4, etc.
C.
The nth triangular number can be calculated by the equation:
1
+ 2 + ... + n = n (n+1)/2
D. We may
say that the sequence of triangle numbers is generated by adding the
natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 +
5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45,
55, ...E. Let us list the factors of the first seven triangle numbers:
1:
1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28
We can see that 28 is the first
triangle number to have over five divisors.
Source Code:
Source Code:
#include
উত্তরমুছুনusing namespace std;
int triangNum(){
static int start=1;
static int nextNum;
nextNum+=start;
/*You can check using this output;
if(nextNum>5000){
return 0;
}
cout<500){
cout<<"Asked Triangular number is: ";
cout<<triangNum();
break;
}else{
triangNum();
}
}
return 0;
}