The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How do I think about recursion.
shivajikobardan
post Dec 11 2022, 02:40 AM
Post #1





Group: Members
Posts: 4
Joined: 5-June 22
Member No.: 28,377



I got the idea for problems like factorials or finding sum from 1 to n, where there's a pattern visible. Like this:

Source:https://99x.io/blog/recursion-is-not-hard-here-is-the-right-way-to-think

I got it for things like addition, subtraction, division, multiplication of two numbers as well.

eg: a+b

=a+b-1+1

=SUM(a+1,b-1)

Now, I am wondering how it'll be for finding a palindrome of a number? I've a solution but I'm not understanding how we came towards it. I'm looking for how to come towards a solution than a solution itself.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 12 2022, 02:37 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Well, here's a recursive definition of a palindrome.

A palindrome is:
- a single letter OR
- two letters the same OR
- a letter followed by a palindrome followed by the same letter

You should be able to rewrite this in any programming-like notation.
HTH!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 07:36 AM