One of the Popular contest in Hackerrank based on a famous site ProjectEuler.net is 


Project Euler+ 

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

So its a lonng contest with pretty big number of questions to be solved.

Coming forth i will be posting the Algorithms and Solutions on Python which i have used to solve the problems.

I go by the name of nis1992 you can check my profile here: 
https://www.hackerrank.com/nis1992 

Lets start with the first Problem:


Project Euler #1: Multiples of 3 and 5

If we 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 N.
Input Format
First line contains T that denotes the number of test cases. This is followed by T lines, each containing an integer, N.
Output Format
For each test case, print an integer that denotes the sum of all the multiples of 3 or 5 below N.
Constraints
1T105
1N109
Sample Input
2
10
100
Sample Output
23
2318

Algorithm:

To solve this problem, a direct approach to check whether a number in the range is divisible 
by 3 or 5, using the modulus operator.

But as the Time complexity for the program will be O(N), where N is the input, if become large, 
our program will take a large time to execute.

Hence we will use some mathematics to solve this.
So if i break the problem in to 3 parts:

  • Sum of numbers divisible by 3 :- 3+6+9+12......
  • Sum of numbers divisible by 5 :- 5+10+15+20.....
  • Sum of numbers divisible by 15 :- 15+30+45.....
We took the case of multiples of 15 as we will encounter cases where we add numbers divisible by both 3 and 5 hence to remove the duplicate values.

    As we know the sum of AP is 
     Sn = (n/2)[2a +(n -1)d]
    So for the 1st Case:
    a=3, d=3
    hence sum becomes: S(n) = (n/2)[2*3 + (n-1)*3]

    Similarly for 2nd and 3rd Case it becomes:
    S(n) = (n/2)[2*5 + (n-1)*5]
    and
    S(n) = (n/2)[2*15 + (n-1)*15]

    And Presto!! Its Done!!

    Just we need to convert that into a code, which is easy ion Python, Check the below code:
    Program:
    t=input()
    while(t>0):
        n=input()
        n-=1
        n3=int(n/3)
        n5=int(n/5)
        n15=int(n/15)
        t-=1
        sum=(n3 * (2*3 + (n3-1)*3))/2
        sum1=(n5 * (2*5 + (n5-1)*5))/2
        sum3=(n15 * (2*15 + (n15-1)*15))/2
        print sum+sum1-sum3
    
    0

    Add a comment

    Greetings!! Here's a series of Cold Golf problems and solutions in Python as a part of 21 days of Code | Code Golf by Skillenza 

    https://skillenza.com/challenge/21days-of-code

    DAY - I

    A Little Complex

    Given n complex numbers each x + yi, where x is the real part and y is the imaginary part, find

    1

    For the need of a simple tabular Grid in your Angular JS application, one of the most basic and simple to use package is angular-ui-grid. The implementation is easy in many of the use cases, but when it comes to extend the limits of the ui-grid, life becomes tough.

    Hey guys, Hope you all are doing great. 

    Algorithm To Convert Post-fix Expression into Infix expression:-

    Scan the Post-fix String from Left to Right. If the character is an Operand, then Push it on to the deque.

    Hey guys, Hope you all are doing great.

    As the first part of this series of Python package and installation we will cover pip vs Conda

    pip vs Conda

    pip

    Python packages only. Compiles everything from source.

    Hey guys,

    Hope you all are doing great. I love Code Golfing, what it brings out in you is the hidden concepts of a programming language and especially the push to implement same thing in numerous ways.

    Hey guys, Hope you all are doing great.

    I have always found Regular expressions or REGEX quite amazing. You can solve your string related problem in just some simple magic of patterns.

    Our brain works very well to identify the pattern in our day to day life.

    1

    Hey guys, Hope you all are doing great. I am back with Some Python Programming tips for

    CODE GOLF Challenges.

    Hey guys, Hope you all are doing great. I am back with Some Python Programming tips for

    CODE GOLF Challenges.

    12

    Hey guys, Hope you all are doing great. I am back with with a byte of python performance.

    I have been playing on codingame.com a lot now a days during my weekends.

    Its cool site for the player aka coders who want to try there hands into gaming domain.

    Hey guys, Hope you all are doing great. I am back with another problem of Project Euler on

    Project Euler #11: Largest product in a grid

    In the 20×20 grid below, four numbers along a diagonal line have been marked in bold.

    Hey guys, Hope you all are doing great.

    Today i came across an intruding method, which is not used in generally but is very effective and we encounter its application a lot of .

    That's 

    Tabibitosan method

    Tabibitosan: is a Japanese word which literally means "Pilgrim".

    8

    Hey guys, 

    Hope you all are doing great. I am back with another problem of Project Euler on

    The sum of the primes below 10 is 2+3+5+7=17

    Find the sum of all the primes not greater than given N.

    Input Format

    The first line contains an integer T i.e. number of the test cases.

    Hey guys, Hope you all are doing great. I am back with a new domain SQL. So the problem goes like, you need to print prime numbers less than 1000.

    Seems easy right!! Just use a for loop check for the list of natural numbers for prime condition whether they are only divisible by 1 and itself.

    13

    Hey guys,

    Hope you all are doing great. I am back with another problem of Project Euler on

    Project Euler #8: Largest product in a series

    Find the greatest product of KK consecutive digits in the NN digit number.

    Input Format

    First line contains TT that denotes the number of test cases.

    Hey guys,

    Hope you all are doing great. I am back with another problem of Project Euler

    Project Euler #2: Even Fibonacci numbers

    Each new term in the Fibonacci sequence is generated by adding the previous two terms.

    2

    Hey guys, 

    Hope you all are doing great. I am back with another problem of Project Euler on

    Project Euler #6: Sum square difference

    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.

    1

    Hey guys, 

    Hope you all are doing great. I am back with another problem of Project Euler on

    Project Euler #5: Smallest multiple

    2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

    Hey guys, 

    Hope you all are doing great. I am back with another problem of Project Euler on

    Project Euler #3: Largest prime factor

    The prime factors of 13195 are 5, 7, 13 and 29.

    What is the largest prime factor of a given number N?

    Input Format

    First line contains T, the number of test cases.

    August 17th, 2015

    Hey Fellas!! So its time to roll on.

    Mathematical series are very interesting in there own ways. I find them interesting as they tickles your brain to know more.

    That you try to find the end. Counting on your fingers, you will get bored or either get tired.

    One of the Popular contest in Hackerrank based on a famous site ProjectEuler.net is 

    Project Euler+ 

    Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve.

    Loading