Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:23:06+00:00 2026-05-29T09:23:06+00:00

I tried to solve project euler 31 : In England the currency is made

  • 0

I tried to solve project euler 31:

In England the currency is made up of pound, £, and pence, p, and
there are eight coins in general circulation:

1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to
make £2 in the following way:

1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p

How many different ways can £2 be
made using any number of coins?

with this code:

#define to2(x) ((x)/2+1)

int to5(x)
{
    int acc=1;
    for(;x>0;x-=5)
        acc+=to2(x);
    return acc;
}

int to10(x)
{
    int acc=1;
    for(;x>0;x-=10)
        acc+=to5(x);
    return acc;
}

int to20(x)
{
    int acc=1;
    for(;x>0;x-=20)
        acc+=to10(x);
    return acc;
}

int to50(x)
{
    int acc=1;
    for(;x>0;x-=50)
        acc+=to20(x);
    return acc;
}

int to100(x)
{
    int acc=1;
    for(;x>0;x-=100)
        acc+=to50(x);
    return acc;
}

int main()
{
    int test = to100(200)+1;
    printf("%d",test);
    return 0;
}

But the code gives 73685, not 73682 but I don’t know why, could someone help me plz?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:23:06+00:00Added an answer on May 29, 2026 at 9:23 am

    Why do you initialize acc to 1? (It makes sense when x is a multiple of the number of the function, but only then.) change it to 0, and change the loop condition to x>=0. (If I understood your code).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to solve problems from Project Euler. I know my method would work
I got nearly no knowledge of haskell and tried to solve some Project Euler
I am trying to solve project euler problem 18 . http://projecteuler.net/problem=18 I tried a
Recently, I tried to solve Problem 23 of Project Euler . For that I
I tried to solve problem# 276 from Project Euler , but without success so
I have been trying to solve Project Euler's problem #59 for a while, and
I am trying to solve Euler's Project #2 and I keep getting the answer
I am trying to solve math problems with Ruby from the Project Euler. Here
I'm writing some disposable Haskell scripts to solve some of the Project Euler problems.
I'm currently trying to solve problem 18 of project Euler . The goal is:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.