Results 1 to 2 of 2

Math Help - matlab palindrome help

  1. #1
    Newbie
    Joined
    Dec 2012
    From
    uk
    Posts
    1

    matlab palindrome help

    i need to create a program that shows a 4 digit palindrome, make sure it can be divisible by 11 and show how many term is used,

    so far i have

    "for a = 1 : 9
    for b = 0 : 9


    results= a*1000+b*100+b*10+a;

    if (rem(results,11)==0);
    fprintf('The number %d is divisble by 11.\n ', results);
    end

    end
    end "

    and results are
    "The number 1001 is divisble by 11.
    The number 1111 is divisble by 11.
    The number 1221 is divisble by 11.
    The number 1331 is divisble by 11.
    The number 1441 is divisble by 11.
    The number 1551 is divisble by 11.
    The number 1661 is divisble by 11.
    The number 1771 is divisble by 11.
    The number 1881 is divisble by 11.
    The number 1991 is divisble by 11.
    The number 2002 is divisble by 11.
    The number 2112 is divisble by 11.
    The number 2222 is divisble by 11.
    The number 2332 is divisble by 11.
    The number 2442 is divisble by 11."
    ect

    but i dont noe how to do that, i tried alot of ways, what am i doing wrong

    thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Jan 2013
    From
    United Kingdom
    Posts
    1

    Re: matlab palindrome help

    You need to put a count function in this, like so
    count=0

    for a = 1 : 9
    for b = 0 : 9


    results= a*1000+b*100+b*10+a;

    if (rem(results,11)==0);
    fprintf('The number %d is divisble by 11.\n ', results);
    count= count +1
    end

    end
    end

    fprintf('There are %d terms divisible by 11. \n' , count)

    Greenwich matlab course work?? name the varible count something else as this is what i called it in my course work :P
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. smallest five-digit palindrome
    Posted in the Number Theory Forum
    Replies: 7
    Last Post: January 10th 2011, 05:34 AM
  2. Matlab Help!
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 18th 2010, 08:51 PM
  3. ODE matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 9th 2010, 11:27 PM
  4. Palindrome
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: January 11th 2009, 12:52 AM
  5. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 05:40 PM

Search Tags


/mathhelpforum @mathhelpforum