clc;close all;c=0;k=0;for i=10:1:9999 if i == fliplr(i) disp (['The string, ' i ', is a palindrome.'])else disp (['The string, ' i ', is not a palindrome.']) num1=i; for j=1:50:1reverse=0;while num1 > 0 t = mod(num1,10); reverse = 10*reverse+t; num1 = (num1-t)/10;endk=num1+reverse; if k == fliplr(k) disp (['The string',k,' is a palindrome after folloowing iteration',j])end end c=c+1; disp(c)endend
MATLAB: Hey. the problem statement is find lychrel numkbers upto 10000.i have done the coding accordingly but it is showing random characters in output..plz help guys
lychrel numbers
Related Question
- How do you write a matlab function that identifies if a string is a palindrome or not
- Very simple question about strings
- How to reverse a string using a FOR loop
- How number character array to single number conversion can be performed
- Must I add this line at the start of the function for it to return correctly
Best Answer