Answer:
The factorial of 3=6
Explanation:
Following are the description of the given question
- This is JavaScript code .Here items are the variable that are holding the integer value "3".
- After that there is 2 loop are iterating one is outer and one inner loop.
- When i=1 1<=3 the condition of outer loop is true the control moves the inner loop .
- In the inner loop there is variable result that is initialized by 1 Now checking the condition of inner loop j=i i.e j=1 1>=1 condition of inner loop is true it executed the statement inside the inner loop so result =1 .Now we increment the value of i of the outer loop.
- i=2 2<=3 the condition of outer loop is true the control moves the inner loop .
- In the inner loop there is variable result that is initialized by 1 Now checking the condition of inner loop j=i i.e j=2 2>=1 condition of inner loop is true it executed the statement inside the inner loop so result =2 .Now we increment the value of i of the outer loop.
- Now i=3 3<=3 the condition of outer loop is true the control moves the inner loop .
- In the inner loop there is variable result that is initialized by 1 Now checking the condition of inner loop j=i i.e j=3 3>=1 condition of inner loop is true it executed the statement inside the inner loop so result =6 .Now we increment the value of i of the outer loop.
- i=4 4<=3 the condition of outer loop is false the control moves from the outer loop.
- It print The factorial of 3=6
Answer:
See explaination
Explanation:
def one_diff(s1,s2):#mthod return true if s1 and s2 has one difference
l1=list(s1)#store characters to list
l2=list(s2)
c=0
if len(l1)!=len(l2):
return False
for i in l1:
if i in l2:#for each character if it is in l1 and l2 continue
continue
else:
c+=1
if c==1:
return True#ret True if cis 1 else False
return False
def exchange(s,*k):#method that exchanges characters
l=list(k)
if len(l)!=0:#check validity of arguments
for i in l:
if i<0 and i+(2*i)>len(s):
res=s
elif i>len(s):
res=s
return res
if len(l)==0:#if no indexes are given
c1=s[0]
c2=s[-1]
res=c2
res=res+s[1:]
res=res[0]+res[1:].replace(c2,c1)
return (res)
elif len(l)==1:#if one index is given
c1=s[l[0]]
c2=s[-1]
res=''
for i in s:
if i==c1 or i==c2:
if i==c2:
res+=c1
else:
res+=c2
else:
res+=i
return (res)
else:#if two indexes are given
c1=s[l[0]]
c2=s[l[1]]
res=''
for i in s:
if i==c1 or i==c2:
if i==c2:
res+=c1
else:
res+=c2
else:
res+=i
return (res)
def is_chain(*k):#method that checks words for one difference
l=list(k)
if len(l)==0:
return False
if len(l)==1:
return True
if len(l)>1:
for i in range(len(l)-1):#for two words in l
if one_diff(l[i],l[i+1]):#call one_diff method
continue
else:
return False
return True
def scramble(s):#method that exchanges characters
i=0
while i<len(s)-1:
s=exchange(s,i,i+1)
i+=2
print(s)
please check out the screenshots in attachment.
Answer:
Answer explained below
Explanation:
Yes, you can let Set-uid program that is owned by root to run your code instead of /bin/ls but it has it's own drawbacks and is actually not safe.
As you can not rely on that since some of the shells if different from the ruid drop an euid which is actually not safe.
execl("/bin/ls", "ls",(char *)0);
run this under your main program.
Since it can have a root previlege,
-$ cd /tmp/
/tmp$ sudo su
:/tmp# gcc -o system system.c
:/tmp# chmod u+s system // changing file permissions
:/tmp# exit
exit
:/tmp$ cp /bin/sh /tmp/ls
:/tmp$ ./system
<u>Steps:
</u>
1. The first thing you need to do is copy /bin/sh to /tmp.
2. After copying /bin/sh to /tmp set a new name ls but make sure your sh ->.zsh.
3. Set PATH to current directory. /tmp.
4. Compile
5. Run the program system and you can get your root previledge.
Now, with the above exmaple if you change /bin/sh soo that it points back to /bin/bash and repeat all the previous steps, you will not be able to get your root previledges.
In regards to the rules of compaction, the IPv6 address 2001:0db8:0000:0000:0000:ff00:0012:3456 could also be written as 2001:db8::ff00:12:3456.
<h3>What is IPv6?</h3>
The IPv6 address is known to be a form of Internet Layer protocol made for packet-switched internetworking and it helps to give an end-to-end datagram movement in course of multiple IP networks.
Note that, In regards to the rules of compaction, the IPv6 address 2001:0db8:0000:0000:0000:ff00:0012:3456 could also be written as 2001:db8::ff00:12:3456.
Learn more aboutIPv6 address from
brainly.com/question/5296366
#SPJ1