Largest product in a series

Largest product in a series
Largest product in a series Problem Find the greatest product of five consecutive digits in the 1000-digit number.

How to convert string to integer

How to convert string to integer
Problem How to convert string to integer in c programming language Try it /** @Author: Tan Nguyen @Website: http://ngtan.com */ #include <stdio.h> #include <stdlib.h> int main() { int number; char buffer[256]; printf( "Please enter a number: " ); fgets( buffer, 256, stdin ); number = atoi( buffer ); printf( "%d", number ); return 0; } ...

Special Pythagorean triplet

Special Pythagorean triplet
Special Pythagorean triplet Problem A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. Algorithm We have a < b < c and a + b + c = ...

Largest prime factor

Largest prime factor
Largest prime factor Problem The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?   Algorithm Let the given number be n and let k = 2, 3, 4, 5, … . For each k, if it is a factor of n then we divide ...

What is the 10001st prime number

What is the 10001st prime number
10001st prime Problem By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number?   Algorithm We want to looking for the 10001st prime number. We have limit = 10001 and we knew 2 is only even ...

Find the largest palindrome made from the product of two 3-digit numbers

Find the largest palindrome made from the product of two 3-digit numbers
Largest palindrome product Problem A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99. Find the largest palindrome made from the product of two 3-digit numbers.   If a and b are 3-digits long then they must lie between 100 and 999 ...

Sum square difference

Sum square difference
Sum square difference Problem The sum of the squares of the first ten natural numbers is, 12 + 22 + … + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ...

Smallest multiple

Smallest multiple
Smallest multiple Problem 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? Algorithm In this case, K = 20 Let N be the smallest number that ...

How to reverse a number or digits using c programming

How to reverse a number or digits using c programming
C All-in-One Desk Reference For Dummies Problem How to reverse a number or digits using c programming? Try it /** @Author: Tan Nguyen @Website: http://ngtan.com */ #include <stdio.h> int Reversed ( int number ) { int reversed_number = 0; while ( number ) { reversed_number = reversed_number * 10 + number % 10; number /= ...

Convert hexadecimal number to binary number

Convert hexadecimal number to binary number
Problem How to convert hexadecimal number to binary number using c programming? Hexadecimal  to binary table We want to convert hexadecimal number to binary number. We will replace each hexadecimal digit to binary values using the above table. Try it /** @Author: Tan Nguyen @Website: http://ngtan.com */ #include <stdio.h> #include <string.h> #define MAX 1000 void ...