Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
You are given a number stored in a variable with the namenum

Find out the value obtained from the expressioni % 10, whereiconsists of all the values from 1 to the value stored innum, includingnum


Input
The first and the only line of the input contains the value stored innum


Output
Print the value obtained after doing the operation,i % 10, whereirefers to all the values from 1 to the number stored innum, including that as well

Note : Print all the values on a new line

Sample Input 1

7
Sample Output 1

1
2
3
4
5
6
7
Hint

In the sample test case, the value stored in the variablenum = 7

All the values in the range from 1 to 7 are put in the expressioni % 10, such that

1 % 10 = 1
2 % 10 = 2
3 % 10 = 3
4 % 10 = 4
5 % 10 = 5
6 % 10 = 6
7 % 10 = 7

Therefore, the required output is

1
2
3
4
5
6
7

What I have tried:

please solve this problem in javascript
Posted
Updated 3-Aug-22 5:15am
v2
Comments
Ravi Kumar 53 19-Aug-23 8:22am    
You are given a number stored in a variable with the name num

Find out the value obtained from the expression i x
% 10, where I consists of all the values from 1 to the value stored in num, including num

Quote:
please solve this problem in javascript
No, this is your assignment so you are expected to do the research and actual work. You could start by studying JavaScript Operators[^].
 
Share this answer
 
Comments
EX BRUTAL 3-Aug-22 9:45am    
i solve this problem.But test cases are failed .i need ur help
Richard MacCutchan 3-Aug-22 10:23am    
Then you need to explain what the problem is, we cannot guess what help you need.
Richard MacCutchan 3-Aug-22 11:01am    
NB 19 / 10 = 1 remainder 9
So 19 % 10 = 9
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

But I'll give you a hint: think about what the % operator does and it's fairly obvious what the range of values is going to be. Try it on paper and you'll see what I mean.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
EX BRUTAL 3-Aug-22 10:06am    
ineed help in
input : 19
output: 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9
how to get output like above
my output : 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
i dont need full solution , i need your help
OriginalGriff 3-Aug-22 10:19am    
As I said, look at what the % operator actually does. When you know that, it's pretty obvious!

To the point where I can't "tell you what to do" without writing the damn code for you! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900